

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>ALASpy.header &mdash; ALASpy 0.1.1 documentation</title>
    
    <link rel="stylesheet" href="../../_static/default.css" type="text/css" />
    <link rel="stylesheet" href="../../_static/pygments.css" type="text/css" />
    
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
        URL_ROOT:    '../../',
        VERSION:     '0.1.1',
        COLLAPSE_INDEX: false,
        FILE_SUFFIX: '.html',
        HAS_SOURCE:  true
      };
    </script>
    <script type="text/javascript" src="../../_static/jquery.js"></script>
    <script type="text/javascript" src="../../_static/underscore.js"></script>
    <script type="text/javascript" src="../../_static/doctools.js"></script>
    <script type="text/javascript" src="../../_static/sidebar.js"></script>
    <link rel="top" title="ALASpy 0.1.1 documentation" href="../../index.html" />
    <link rel="up" title="Module code" href="../index.html" /> 
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="../../index.html">ALASpy 0.1.1 documentation</a> &raquo;</li>
          <li><a href="../index.html" accesskey="U">Module code</a> &raquo;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  <h1>Source code for ALASpy.header</h1><div class="highlight"><pre>
<span class="c"># -*- coding: utf-8 -*-</span>
<span class="sd">&quot;&quot;&quot; The LAS Object Header module.</span>

<span class="sd">  :Author:</span>
<span class="sd">    - 2010-2012 Nicola Creati and Roberto Vidmar</span>

<span class="sd">  :Revision:  $Revision: 6 $</span>
<span class="sd">              $Date: 2012-12-27 11:24:41 +0100 (Thu, 27 Dec 2012) $</span>

<span class="sd">  :Copyright: 2010-2012</span>
<span class="sd">              Nicola Creati &lt;ncreati@inogs.it&gt;</span>
<span class="sd">              Roberto Vidmar &lt;rvidmar@inogs.it&gt;</span>

<span class="sd">  :License: MIT/X11 License (see :download:`LICENSE.txt</span>
<span class="sd">                             &lt;../../LICENSE.txt&gt;`)</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">struct</span>
<span class="kn">import</span> <span class="nn">time</span>
<span class="kn">import</span> <span class="nn">types</span>
<span class="kn">import</span> <span class="nn">uuid</span>
<span class="kn">import</span> <span class="nn">cPickle</span>
<span class="kn">import</span> <span class="nn">numpy</span> <span class="kn">as</span> <span class="nn">np</span>
<span class="k">try</span><span class="p">:</span>
  <span class="kn">from</span> <span class="nn">osgeo</span> <span class="kn">import</span> <span class="n">osr</span>
<span class="k">except</span> <span class="ne">ImportError</span><span class="p">:</span>
  <span class="n">osr</span> <span class="o">=</span> <span class="bp">None</span>

<span class="kn">from</span> <span class="nn">geotiffKeys</span> <span class="kn">import</span> <span class="n">GeotiffKeys</span>
<span class="kn">from</span> <span class="nn">geotif</span> <span class="kn">import</span> <span class="n">normalize</span><span class="p">,</span> <span class="n">geoKeysFromWkt</span>
<span class="kn">from</span> <span class="nn">lasExceptions</span> <span class="kn">import</span> <span class="p">(</span><span class="n">InvalidPointDataFormatID</span><span class="p">,</span> <span class="n">MustBeImplemented</span><span class="p">,</span>
  <span class="n">UnimplementedException</span><span class="p">,</span> <span class="n">InvalidLASFile</span><span class="p">)</span>

<span class="c">#-------------------------------------------------------------------------------</span>
<div class="viewcode-block" id="sizeBytes"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.sizeBytes">[docs]</a><span class="k">def</span> <span class="nf">sizeBytes</span><span class="p">(</span><span class="n">dataType</span><span class="p">,</span> <span class="n">n</span><span class="p">):</span>
  <span class="sd">&quot;&quot;&quot; Return size in bytes of n instances of data of type `dataType`</span>

<span class="sd">    :param dataType: any in (cbBhHiIqQfd)</span>
<span class="sd">    :type  dataType: char</span>
<span class="sd">    :param n: number of instances</span>
<span class="sd">    :type  n: int</span>
<span class="sd">    :returns: size in bytes</span>
<span class="sd">    :rtype: int</span>
<span class="sd">    :raises: :class:`TypeError`</span>
<span class="sd">  &quot;&quot;&quot;</span>
  <span class="k">if</span> <span class="n">dataType</span> <span class="ow">in</span> <span class="p">(</span><span class="n">AbstractRecord</span><span class="o">.</span><span class="n">INT8</span><span class="p">,</span> <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">UINT8</span><span class="p">,</span>
    <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">SINT8</span><span class="p">,</span> <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">SCHAR</span><span class="p">):</span>
    <span class="n">b</span> <span class="o">=</span> <span class="mi">1</span>
  <span class="k">elif</span> <span class="n">dataType</span> <span class="ow">in</span> <span class="p">(</span><span class="n">AbstractRecord</span><span class="o">.</span><span class="n">INT16</span><span class="p">,</span> <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">UINT16</span><span class="p">):</span>
    <span class="n">b</span> <span class="o">=</span> <span class="mi">2</span>
  <span class="k">elif</span> <span class="n">dataType</span> <span class="ow">in</span> <span class="p">(</span><span class="n">AbstractRecord</span><span class="o">.</span><span class="n">INT32</span><span class="p">,</span> <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">UINT32</span><span class="p">,</span>
    <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">):</span>
    <span class="n">b</span> <span class="o">=</span> <span class="mi">4</span>
  <span class="k">elif</span> <span class="n">dataType</span> <span class="ow">in</span> <span class="p">(</span><span class="n">AbstractRecord</span><span class="o">.</span><span class="n">INT64</span><span class="p">,</span> <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">UINT64</span><span class="p">,</span>
    <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">):</span>
    <span class="n">b</span> <span class="o">=</span> <span class="mi">8</span>
  <span class="k">else</span><span class="p">:</span>
    <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s">&quot;Data type &#39;</span><span class="si">%s</span><span class="s">&#39; not understood&quot;</span> <span class="o">%</span> <span class="n">dataType</span><span class="p">)</span>
  <span class="k">return</span> <span class="n">b</span> <span class="o">*</span> <span class="n">n</span>

<span class="c">#-------------------------------------------------------------------------------</span></div>
<div class="viewcode-block" id="getLongest"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.getLongest">[docs]</a><span class="k">def</span> <span class="nf">getLongest</span><span class="p">(</span><span class="n">l</span><span class="p">):</span>
  <span class="sd">&quot;&quot;&quot; Return length of longest string in list l *OR*</span>
<span class="sd">             length of longest line in string l</span>

<span class="sd">    :param l: list of strings or string of lines</span>
<span class="sd">    :type  l: tuple, list or string</span>
<span class="sd">    :returns: length of longest string in list l *OR*</span>
<span class="sd">              length of longest line in string l</span>
<span class="sd">    :rtype: int</span>
<span class="sd">  &quot;&quot;&quot;</span>
  <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">l</span><span class="p">,</span> <span class="p">(</span><span class="nb">list</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">)):</span>
    <span class="k">return</span> <span class="nb">max</span><span class="p">([</span><span class="nb">len</span><span class="p">(</span><span class="n">i</span><span class="o">.</span><span class="n">splitlines</span><span class="p">()[</span><span class="mi">0</span><span class="p">])</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">l</span><span class="p">])</span>
  <span class="k">else</span><span class="p">:</span>
    <span class="k">return</span> <span class="nb">max</span><span class="p">([</span><span class="nb">len</span><span class="p">(</span><span class="n">i</span><span class="p">)</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">l</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s">&#39;</span><span class="se">\n</span><span class="s">&#39;</span><span class="p">)])</span>

<span class="c">#-------------------------------------------------------------------------------</span></div>
<span class="k">def</span> <span class="nf">addGet</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">):</span>
  <span class="sd">&quot;&quot;&quot; Add getter method for attribute `name`</span>
<span class="sd">  &quot;&quot;&quot;</span>
  <span class="k">def</span> <span class="nf">get</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="k">return</span> <span class="nb">eval</span><span class="p">(</span><span class="s">&#39;self._</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">name</span><span class="p">)</span>
  <span class="k">return</span> <span class="n">get</span>

<span class="c">#-------------------------------------------------------------------------------</span>
<span class="k">def</span> <span class="nf">addSet</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">name</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
  <span class="sd">&quot;&quot;&quot; Add setter method for attribute `name`</span>
<span class="sd">  &quot;&quot;&quot;</span>
  <span class="k">def</span> <span class="nf">set</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">value</span><span class="p">):</span>
    <span class="nb">setattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s">&#39;_</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">name</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
  <span class="k">return</span> <span class="nb">set</span>

<span class="c">#-------------------------------------------------------------------------------</span>
<div class="viewcode-block" id="nonull"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.nonull">[docs]</a><span class="k">def</span> <span class="nf">nonull</span><span class="p">(</span><span class="n">s</span><span class="p">):</span>
  <span class="sd">&quot;&quot;&quot; Return s truncated to the first null character</span>

<span class="sd">    :param s: string to truncate</span>
<span class="sd">    :type  s: string</span>
<span class="sd">    :returns: s truncated to the first null character</span>
<span class="sd">    :rtype: string</span>
<span class="sd">  &quot;&quot;&quot;</span>
  <span class="k">return</span> <span class="n">s</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s">&#39;</span><span class="se">\x00</span><span class="s">&#39;</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>

<span class="c">#-------------------------------------------------------------------------------</span></div>
<div class="viewcode-block" id="string_clean"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.string_clean">[docs]</a><span class="k">def</span> <span class="nf">string_clean</span><span class="p">(</span><span class="n">s</span><span class="p">):</span>
  <span class="sd">&quot;&quot;&quot; Remove unprintable characters from string s and cut it at first</span>
<span class="sd">      null character.</span>

<span class="sd">    :param s: string to clean</span>
<span class="sd">    :type  s: string</span>
<span class="sd">    :returns: s with all unprintable characters removed and truncated to first</span>
<span class="sd">              null character</span>
<span class="sd">    :rtype: string</span>
<span class="sd">  &quot;&quot;&quot;</span>
  <span class="k">try</span><span class="p">:</span>
    <span class="n">s</span> <span class="o">+</span> <span class="s">&#39;&#39;</span>
  <span class="k">except</span><span class="p">:</span>
    <span class="k">return</span> <span class="n">s</span>
  <span class="k">else</span><span class="p">:</span>
    <span class="c"># Define my own &quot;printable&quot; charset</span>
    <span class="n">ascii256</span> <span class="o">=</span> <span class="s">&quot;&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="nb">map</span><span class="p">(</span><span class="nb">chr</span><span class="p">,</span> <span class="nb">range</span><span class="p">(</span><span class="mi">256</span><span class="p">)))</span>
    <span class="n">printable</span> <span class="o">=</span> <span class="s">&quot;&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="nb">map</span><span class="p">(</span><span class="nb">chr</span><span class="p">,</span> <span class="nb">range</span><span class="p">(</span><span class="mi">32</span><span class="p">,</span> <span class="mi">127</span><span class="p">)))</span>
    <span class="n">flt</span> <span class="o">=</span> <span class="s">&quot;&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">((</span><span class="s">&#39;.&#39;</span><span class="p">,</span> <span class="n">c</span><span class="p">)</span> <span class="p">[</span><span class="n">c</span> <span class="ow">in</span> <span class="n">printable</span><span class="p">]</span> <span class="k">for</span> <span class="n">c</span> <span class="ow">in</span> <span class="n">ascii256</span><span class="p">)</span>
    <span class="k">return</span> <span class="n">nonull</span><span class="p">(</span><span class="n">s</span><span class="p">)</span><span class="o">.</span><span class="n">translate</span><span class="p">(</span><span class="n">flt</span><span class="p">)</span>

<span class="c">#-------------------------------------------------------------------------------</span></div>
<div class="viewcode-block" id="pad_with_nulls"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.pad_with_nulls">[docs]</a><span class="k">def</span> <span class="nf">pad_with_nulls</span><span class="p">(</span><span class="n">instring</span><span class="p">,</span> <span class="n">l</span><span class="p">):</span>
  <span class="sd">&quot;&quot;&quot; Pad string instring to length l with null (ASCII 0) characters</span>
<span class="sd">      Truncate instring to l characters if necessary</span>

<span class="sd">    :param instring: string to pad</span>
<span class="sd">    :type  instring: string</span>
<span class="sd">    :returns: instring padded with null characters to length l</span>
<span class="sd">    :rtype: string</span>
<span class="sd">  &quot;&quot;&quot;</span>
  <span class="k">return</span> <span class="n">instring</span> <span class="o">+</span> <span class="s">&#39;</span><span class="se">\x00</span><span class="s">&#39;</span> <span class="o">*</span> <span class="nb">max</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="p">(</span><span class="n">l</span> <span class="o">-</span> <span class="nb">len</span><span class="p">(</span><span class="n">instring</span><span class="p">)))</span>

<span class="c">#===============================================================================</span></div>
<div class="viewcode-block" id="AbstractRecord"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.AbstractRecord">[docs]</a><span class="k">class</span> <span class="nc">AbstractRecord</span><span class="p">(</span><span class="nb">object</span><span class="p">):</span>
  <span class="sd">&quot;&quot;&quot; An abstract class for reading and writing structured records.</span>

<span class="sd">  .. warning:: **MUST** be subclassed</span>
<span class="sd">  &quot;&quot;&quot;</span>
  <span class="c"># Size 1</span>
  <span class="n">INT8</span>    <span class="o">=</span> <span class="n">CHAR</span>    <span class="o">=</span> <span class="s">&#39;c&#39;</span>
  <span class="n">SINT8</span>   <span class="o">=</span> <span class="n">SCHAR</span>   <span class="o">=</span> <span class="s">&#39;b&#39;</span>
  <span class="n">UINT8</span>   <span class="o">=</span> <span class="n">UCHAR</span>   <span class="o">=</span> <span class="s">&#39;B&#39;</span> <span class="c"># B is actually unsigned byte</span>
  <span class="c"># Size 2</span>
  <span class="n">INT16</span>   <span class="o">=</span> <span class="n">SHORT</span>   <span class="o">=</span> <span class="s">&#39;h&#39;</span>
  <span class="n">UINT16</span>  <span class="o">=</span> <span class="n">USHORT</span>  <span class="o">=</span> <span class="s">&#39;H&#39;</span>
  <span class="c"># Size 4</span>
  <span class="n">INT32</span>   <span class="o">=</span> <span class="n">LONG</span>    <span class="o">=</span> <span class="s">&#39;i&#39;</span>
  <span class="n">UINT32</span>  <span class="o">=</span> <span class="n">ULONG</span>   <span class="o">=</span> <span class="s">&#39;I&#39;</span>
  <span class="n">FLOAT</span>   <span class="o">=</span> <span class="s">&#39;f&#39;</span>
  <span class="c"># Size 8</span>
  <span class="n">INT64</span>   <span class="o">=</span> <span class="n">LLONG</span>   <span class="o">=</span> <span class="s">&#39;q&#39;</span>
  <span class="n">UINT64</span>  <span class="o">=</span> <span class="n">ULLONG</span>  <span class="o">=</span> <span class="s">&#39;Q&#39;</span>
  <span class="n">DOUBLE</span>  <span class="o">=</span> <span class="s">&#39;d&#39;</span>

  <span class="k">def</span> <span class="nf">_createStructure</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">structure</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Create structure for the current object, define</span>
<span class="sd">        methods to get and set attributes at run time</span>
<span class="sd">        An example of structure:</span>

<span class="sd">        s = (</span>
<span class="sd">          (&#39;Red&#39;,              AbstractRecord.USHORT,  1),</span>
<span class="sd">          (&#39;Green&#39;,            AbstractRecord.USHORT,  1),</span>
<span class="sd">          (&#39;Blue&#39;,             AbstractRecord.USHORT,  1),)</span>

<span class="sd">      :param structure: Tuple defining record structure</span>
<span class="sd">      :type  structure: tuple</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">structure</span> <span class="o">=</span> <span class="n">structure</span>
    <span class="k">for</span> <span class="n">field</span> <span class="ow">in</span> <span class="n">structure</span><span class="p">:</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__dict__</span><span class="p">[</span><span class="s">&#39;_</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">field</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="bp">None</span>

    <span class="c"># Automatically add methods</span>
    <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">n</span> <span class="ow">in</span> <span class="n">structure</span><span class="p">:</span>
      <span class="c"># Add get method for each header item</span>
      <span class="nb">setattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s">&#39;get</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">key</span><span class="p">,</span>
        <span class="n">types</span><span class="o">.</span><span class="n">MethodType</span><span class="p">(</span><span class="n">addGet</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">),</span> <span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">__class__</span><span class="p">))</span>
      <span class="k">exec</span><span class="p">(</span><span class="s">&quot;self.get</span><span class="si">%s</span><span class="s">.__func__.__doc__ = &#39;Return `_</span><span class="si">%s</span><span class="s">` attribute&#39;&quot;</span> <span class="o">%</span>
       <span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">key</span><span class="p">))</span>

      <span class="c"># Add set method for each header item</span>
      <span class="n">value</span> <span class="o">=</span> <span class="nb">eval</span><span class="p">(</span><span class="s">&#39;self._</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">key</span><span class="p">)</span>
      <span class="nb">setattr</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="s">&#39;set</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">key</span><span class="p">,</span>
        <span class="n">types</span><span class="o">.</span><span class="n">MethodType</span><span class="p">(</span><span class="n">addSet</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">),</span> <span class="bp">self</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">__class__</span><span class="p">))</span>
      <span class="c"># Add function documentation through black magic</span>
      <span class="k">exec</span><span class="p">(</span><span class="s">&quot;self.set</span><span class="si">%s</span><span class="s">.__func__.__doc__ = &#39;Set `_</span><span class="si">%s</span><span class="s">` attribute to `value`&#39;&quot;</span> <span class="o">%</span>
       <span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">key</span><span class="p">))</span>

  <span class="k">def</span> <span class="nf">_read</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">source</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Load structure from file or string</span>

<span class="sd">      :param source: where to read data from</span>
<span class="sd">      :type  source: file or string</span>
<span class="sd">      :returns: number of bytes read</span>
<span class="sd">      :rtype: int</span>
<span class="sd">      :raises: :class:`IOError`</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">isReadMode</span><span class="p">():</span>
      <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%s</span><span class="s"> not opened for reading&quot;</span> <span class="o">%</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__class__</span><span class="o">.</span><span class="n">__name__</span><span class="p">)</span>

    <span class="c"># Read record header</span>
    <span class="n">bytesRead</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">n</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="p">:</span>
      <span class="n">nbytes</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">calcsize</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span> <span class="o">*</span> <span class="n">n</span>
      <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">source</span><span class="p">,</span> <span class="nb">file</span><span class="p">):</span>
        <span class="n">string</span> <span class="o">=</span> <span class="n">source</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="n">nbytes</span><span class="p">)</span>
      <span class="k">else</span><span class="p">:</span>
        <span class="n">string</span> <span class="o">=</span> <span class="n">source</span><span class="p">[</span><span class="n">bytesRead</span><span class="p">:</span> <span class="n">bytesRead</span> <span class="o">+</span> <span class="n">nbytes</span><span class="p">]</span>

      <span class="k">if</span> <span class="n">dtype</span> <span class="ow">in</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">UCHAR</span><span class="p">):</span>
        <span class="c"># string</span>
        <span class="n">value</span> <span class="o">=</span> <span class="n">string</span>
        <span class="k">if</span> <span class="n">n</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
          <span class="c"># Format is char but content is a NUMBER!</span>
          <span class="n">value</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">unpack</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">string</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
          <span class="c">#value = ord(value)</span>
      <span class="k">else</span><span class="p">:</span>
        <span class="n">value</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">unpack</span><span class="p">(</span><span class="n">dtype</span> <span class="o">*</span> <span class="n">n</span><span class="p">,</span> <span class="n">string</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">n</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
          <span class="c"># single binary number</span>
          <span class="n">value</span> <span class="o">=</span> <span class="n">value</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
      <span class="n">bytesRead</span> <span class="o">+=</span> <span class="n">nbytes</span>

      <span class="c"># Set attribute according to Record format</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__setattr__</span><span class="p">(</span><span class="s">&#39;_</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
    <span class="k">return</span> <span class="n">bytesRead</span>

<div class="viewcode-block" id="AbstractRecord.sizeBytes"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.AbstractRecord.sizeBytes">[docs]</a>  <span class="k">def</span> <span class="nf">sizeBytes</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return size in bytes of this record</span>

<span class="sd">      :returns: size in bytes of this record</span>
<span class="sd">      :rtype: int</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="nb">sum</span><span class="p">([</span><span class="n">sizeBytes</span><span class="p">(</span><span class="o">*</span><span class="n">item</span><span class="p">[</span><span class="mi">1</span><span class="p">:])</span> <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="p">])</span>
</div>
<div class="viewcode-block" id="AbstractRecord.fieldSize"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.AbstractRecord.fieldSize">[docs]</a>  <span class="k">def</span> <span class="nf">fieldSize</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">field</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return field size in bytes</span>

<span class="sd">      :param field: field name</span>
<span class="sd">      :type  field: string</span>
<span class="sd">      :returns: size in bytes of `field` in this record</span>
<span class="sd">      :rtype: int</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">n</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="p">:</span>
      <span class="k">if</span> <span class="n">key</span> <span class="o">==</span> <span class="n">field</span><span class="p">:</span>
        <span class="k">return</span> <span class="n">sizeBytes</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">n</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="AbstractRecord.allFields"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.AbstractRecord.allFields">[docs]</a>  <span class="k">def</span> <span class="nf">allFields</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return list of all fields in this record</span>

<span class="sd">      :returns: list of all fields in this record</span>
<span class="sd">      :rtype: list</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="p">[</span><span class="n">key</span> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">n</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="p">]</span>
</div>
<div class="viewcode-block" id="AbstractRecord.isReadMode"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.AbstractRecord.isReadMode">[docs]</a>  <span class="k">def</span> <span class="nf">isReadMode</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return True if object is created for reading</span>

<span class="sd">      :raises: :class:`~ALASpy.lasExceptions.MustBeImplemented`</span>

<span class="sd">      .. warning:: **MUST BE REIMPLEMENTED**</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">raise</span> <span class="n">MustBeImplemented</span><span class="p">(</span><span class="s">&quot;isReadMode method must be implemented in subclass&quot;</span><span class="p">)</span>

<span class="c">#===============================================================================</span></div></div>
<div class="viewcode-block" id="PointDataRecord"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord">[docs]</a><span class="k">class</span> <span class="nc">PointDataRecord</span><span class="p">(</span><span class="n">AbstractRecord</span><span class="p">):</span>
  <span class="sd">&quot;&quot;&quot; LAS Point Data Record</span>

<span class="sd">    .. note:: Formats from 0 to 10 are implemented.</span>
<span class="sd">  &quot;&quot;&quot;</span>
  <span class="c"># (Description,        type,    array size)  </span>
  <span class="n">Core14</span> <span class="o">=</span> <span class="p">(</span>
    <span class="p">(</span><span class="s">&#39;X&#39;</span><span class="p">,</span>                <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">LONG</span><span class="p">,</span>    <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;Y&#39;</span><span class="p">,</span>                <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">LONG</span><span class="p">,</span>    <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;Z&#39;</span><span class="p">,</span>                <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">LONG</span><span class="p">,</span>    <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;Intensity&#39;</span><span class="p">,</span>        <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),)</span>
  <span class="n">Core5</span> <span class="o">=</span> <span class="p">(</span>
    <span class="p">(</span><span class="s">&#39;Classification&#39;</span><span class="p">,</span>   <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">UCHAR</span><span class="p">,</span>   <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;ScanAngleRank&#39;</span><span class="p">,</span>    <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">SCHAR</span><span class="p">,</span>   <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;UserData&#39;</span><span class="p">,</span>         <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">UCHAR</span><span class="p">,</span>   <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;PointSourceid&#39;</span><span class="p">,</span>    <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),)</span>
  <span class="n">Core5New</span> <span class="o">=</span> <span class="p">(</span>
    <span class="p">(</span><span class="s">&#39;Classification&#39;</span><span class="p">,</span>   <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">UCHAR</span><span class="p">,</span>   <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;UserData&#39;</span><span class="p">,</span>         <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">UCHAR</span><span class="p">,</span>   <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;ScanAngleRank&#39;</span><span class="p">,</span>    <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">SCHAR</span><span class="p">,</span>   <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;PointSourceid&#39;</span><span class="p">,</span>    <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),)</span>
  <span class="n">GPSTime</span> <span class="o">=</span> <span class="p">(</span>
    <span class="p">(</span><span class="s">&#39;GPSTime&#39;</span><span class="p">,</span>          <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),)</span>
  <span class="n">NIR</span> <span class="o">=</span> <span class="p">(</span>
    <span class="p">(</span><span class="s">&#39;NIR&#39;</span><span class="p">,</span>              <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),)</span>
  <span class="n">RGB</span> <span class="o">=</span> <span class="p">(</span>
    <span class="p">(</span><span class="s">&#39;Red&#39;</span><span class="p">,</span>              <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;Green&#39;</span><span class="p">,</span>            <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;Blue&#39;</span><span class="p">,</span>             <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),)</span>
  <span class="n">WavePackets</span> <span class="o">=</span> <span class="p">(</span>
    <span class="p">(</span><span class="s">&#39;WavePacketDescrIndex&#39;</span><span class="p">,</span>   <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">UCHAR</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;ByteOffsetToWaveData&#39;</span><span class="p">,</span>   <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">ULLONG</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;WaveformPacketSize&#39;</span><span class="p">,</span>     <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">ULONG</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;ReturnPointWaveformLoc&#39;</span><span class="p">,</span> <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;X_at_t&#39;</span><span class="p">,</span>                 <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;Y_at_t&#39;</span><span class="p">,</span>                 <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;Z_at_t&#39;</span><span class="p">,</span>                 <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">FLOAT</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),)</span>

  <span class="n">Format0</span> <span class="o">=</span> <span class="p">(</span><span class="n">Core14</span> <span class="o">+</span> <span class="p">(</span>
    <span class="p">(</span><span class="s">&#39;AByte&#39;</span><span class="p">,</span>            <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">UCHAR</span><span class="p">,</span>   <span class="mi">1</span><span class="p">),)</span> <span class="o">+</span>
    <span class="n">Core5</span><span class="p">)</span>
  <span class="n">Format1</span> <span class="o">=</span> <span class="p">(</span><span class="n">Format0</span> <span class="o">+</span> <span class="n">GPSTime</span><span class="p">)</span>
  <span class="n">Format2</span> <span class="o">=</span> <span class="p">(</span><span class="n">Format0</span> <span class="o">+</span> <span class="n">RGB</span><span class="p">)</span>
  <span class="n">Format3</span> <span class="o">=</span> <span class="p">(</span><span class="n">Format1</span> <span class="o">+</span> <span class="n">RGB</span><span class="p">)</span>
  <span class="n">Format4</span> <span class="o">=</span> <span class="p">(</span><span class="n">Format1</span> <span class="o">+</span> <span class="n">WavePackets</span><span class="p">)</span>
  <span class="n">Format5</span> <span class="o">=</span> <span class="p">(</span><span class="n">Format1</span> <span class="o">+</span> <span class="n">RGB</span> <span class="o">+</span> <span class="n">WavePackets</span><span class="p">)</span>

  <span class="n">Format6</span> <span class="o">=</span> <span class="p">(</span><span class="n">Core14</span> <span class="o">+</span> <span class="p">(</span>
    <span class="p">(</span><span class="s">&#39;2Bytes&#39;</span><span class="p">,</span>           <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">UINT8</span><span class="p">,</span>  <span class="mi">2</span><span class="p">),)</span> <span class="o">+</span>
    <span class="n">Core5New</span> <span class="o">+</span> <span class="n">GPSTime</span><span class="p">)</span>
  <span class="n">Format7</span> <span class="o">=</span> <span class="p">(</span><span class="n">Format6</span> <span class="o">+</span> <span class="n">RGB</span><span class="p">)</span>
  <span class="n">Format8</span> <span class="o">=</span> <span class="p">(</span><span class="n">Format7</span> <span class="o">+</span> <span class="n">NIR</span><span class="p">)</span>
  <span class="n">Format9</span> <span class="o">=</span> <span class="p">(</span><span class="n">Format6</span> <span class="o">+</span> <span class="n">WavePackets</span><span class="p">)</span>
  <span class="n">Format10</span> <span class="o">=</span> <span class="p">(</span><span class="n">Format7</span> <span class="o">+</span> <span class="n">WavePackets</span><span class="p">)</span>

  <span class="n">OneByteFields</span> <span class="o">=</span> <span class="p">(</span>
    <span class="s">&#39;Return Number&#39;</span><span class="p">,</span>
    <span class="s">&#39;Number Of Returns&#39;</span><span class="p">,</span>
    <span class="s">&#39;Scan Direction Flag&#39;</span><span class="p">,</span>
    <span class="s">&#39;Edge Of Flight Line&#39;</span><span class="p">,</span>
    <span class="p">)</span>
  <span class="n">TwoByteFields</span> <span class="o">=</span> <span class="n">OneByteFields</span> <span class="o">+</span> <span class="p">(</span>
    <span class="s">&#39;Classification Flags&#39;</span><span class="p">,</span>
    <span class="s">&#39;Scanner Channel&#39;</span><span class="p">,</span>
    <span class="p">)</span>
<div class="viewcode-block" id="PointDataRecord.__init__"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord.__init__">[docs]</a>  <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">header</span><span class="p">,</span> <span class="n">index</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Create a new Point Data Record instance.</span>

<span class="sd">      .. note:: If index is not specified no record is actually read.</span>
<span class="sd">      ..</span>

<span class="sd">      :param header: Las Header</span>
<span class="sd">      :type  header: :class:`Header` instance</span>
<span class="sd">      :raises: :class:`~ALASpy.lasExceptions.UnimplementedException`</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_header</span> <span class="o">=</span> <span class="n">header</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="o">=</span> <span class="n">index</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_format</span> <span class="o">=</span> <span class="n">header</span><span class="o">.</span><span class="n">getPointDataFormatID</span><span class="p">()</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_format</span> <span class="o">&gt;</span> <span class="mi">3</span><span class="p">:</span>
      <span class="k">raise</span> <span class="n">UnimplementedException</span><span class="p">(</span>
        <span class="s">&quot;PointDataFormat </span><span class="si">%d</span><span class="s"> not yet tested&quot;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_format</span><span class="p">)</span>
    <span class="n">structure</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__getattribute__</span><span class="p">(</span><span class="s">&#39;Format</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_format</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_createStructure</span><span class="p">(</span><span class="n">structure</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">index</span> <span class="ow">is</span> <span class="ow">not</span> <span class="bp">None</span><span class="p">:</span>
      <span class="n">nbytes</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_read</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="o">.</span><span class="n">fid</span><span class="p">())</span>
</div>
<div class="viewcode-block" id="PointDataRecord.fieldInfo"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord.fieldInfo">[docs]</a>  <span class="k">def</span> <span class="nf">fieldInfo</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">field</span><span class="p">,</span> <span class="n">xyzType</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return field dtype and number of elements.</span>

<span class="sd">      :param field: field name</span>
<span class="sd">      :type  field: string</span>
<span class="sd">      :param xyzType: dtype for X, Y and Z</span>
<span class="sd">      :type  xyzType: numpy.dtype</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">n</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="p">:</span>
      <span class="k">if</span> <span class="n">key</span> <span class="o">==</span> <span class="n">field</span><span class="p">:</span>
        <span class="k">if</span> <span class="n">key</span> <span class="ow">in</span> <span class="s">&#39;XYZ&#39;</span><span class="p">:</span>
          <span class="k">return</span> <span class="n">xyzType</span>
        <span class="k">else</span><span class="p">:</span>
          <span class="k">return</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">n</span>
</div>
<div class="viewcode-block" id="PointDataRecord.makeDtype"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord.makeDtype">[docs]</a>  <span class="k">def</span> <span class="nf">makeDtype</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">fields</span><span class="o">=</span><span class="s">&#39;all&#39;</span><span class="p">,</span> <span class="n">skip</span><span class="o">=</span><span class="bp">None</span><span class="p">,</span> <span class="n">xyzType</span><span class="o">=</span><span class="n">np</span><span class="o">.</span><span class="n">int32</span><span class="p">,</span> <span class="n">dummies</span><span class="o">=</span><span class="bp">True</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return dtype for reading / writing</span>

<span class="sd">      :param fields:  list of field names to read (default is all fields)</span>
<span class="sd">      :type  fields:  list of strings</span>
<span class="sd">      :param skip:    list of field names to skip (default is skip None)</span>
<span class="sd">      :type  skip:    list of strings</span>
<span class="sd">      :param xyzType: X, Y, Z will have this data type (default is np.int32)</span>
<span class="sd">      :type  xyzType: numpy.dtype</span>
<span class="sd">      :param dummies: if True add dummy fields for reading</span>
<span class="sd">      :type  dummies: bool</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">allfields</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">allFields</span><span class="p">()</span>

    <span class="k">if</span> <span class="n">fields</span> <span class="o">==</span> <span class="s">&#39;all&#39;</span><span class="p">:</span>
      <span class="n">fields</span> <span class="o">=</span> <span class="n">allfields</span>

    <span class="n">formats</span> <span class="o">=</span> <span class="p">[]</span>
    <span class="n">names</span> <span class="o">=</span> <span class="p">[]</span>
    <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="k">for</span> <span class="n">f</span> <span class="ow">in</span> <span class="n">allfields</span><span class="p">:</span>
      <span class="k">if</span> <span class="n">fields</span><span class="o">.</span><span class="n">__contains__</span><span class="p">(</span><span class="n">f</span><span class="p">):</span>
        <span class="n">formats</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">fieldInfo</span><span class="p">(</span><span class="n">f</span><span class="p">,</span> <span class="n">xyzType</span><span class="p">))</span>
        <span class="n">names</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">f</span><span class="p">)</span>
      <span class="k">elif</span> <span class="n">dummies</span><span class="p">:</span>
        <span class="n">formats</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s">&#39;V&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">fieldSize</span><span class="p">(</span><span class="n">f</span><span class="p">)))</span>
        <span class="n">names</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s">&#39;dummy&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">))</span>
        <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span>

    <span class="k">if</span> <span class="n">skip</span> <span class="ow">and</span> <span class="n">dummies</span><span class="p">:</span>
      <span class="n">names</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s">&#39;dummy&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">i</span><span class="p">))</span>
      <span class="n">formats</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s">&#39;V&#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sizeBytes</span><span class="p">()</span> <span class="o">*</span> <span class="n">skip</span><span class="p">))</span>

    <span class="k">return</span> <span class="n">np</span><span class="o">.</span><span class="n">dtype</span><span class="p">({</span><span class="s">&#39;names&#39;</span><span class="p">:</span> <span class="n">names</span><span class="p">,</span> <span class="s">&#39;formats&#39;</span><span class="p">:</span> <span class="n">formats</span><span class="p">})</span>
</div>
<div class="viewcode-block" id="PointDataRecord.__repr__"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord.__repr__">[docs]</a>  <span class="k">def</span> <span class="nf">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; :class:`PointDataRecord` representation with format and index (if any)</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">cname</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__class__</span><span class="o">.</span><span class="n">__name__</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
      <span class="k">return</span> <span class="s">&#39;</span><span class="si">%s</span><span class="s">[</span><span class="si">%s</span><span class="s">]:</span><span class="se">\n</span><span class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span><span class="n">cname</span><span class="p">,</span> <span class="bp">None</span><span class="p">)</span>

    <span class="k">return</span> <span class="s">&#39;</span><span class="si">%s</span><span class="s">[</span><span class="si">%d</span><span class="s">], Format </span><span class="si">%d</span><span class="s">:</span><span class="se">\n</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span>
      <span class="n">cname</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_format</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">__str__</span><span class="p">())</span>
</div>
<div class="viewcode-block" id="PointDataRecord.__str__"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord.__str__">[docs]</a>  <span class="k">def</span> <span class="nf">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; :class:`PointDataRecord` representation</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
      <span class="k">return</span> <span class="bp">None</span>

    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_format</span> <span class="o">&lt;</span> <span class="mi">6</span><span class="p">:</span>
      <span class="n">bitFieldNames</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">OneByteFields</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="n">bitFieldNames</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">TwoByteFields</span>
    <span class="n">ml</span> <span class="o">=</span> <span class="n">getLongest</span><span class="p">(</span>
      <span class="nb">tuple</span><span class="p">([</span><span class="n">key</span> <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">n</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="p">])</span> <span class="o">+</span> <span class="n">bitFieldNames</span><span class="p">)</span>
    <span class="n">ff</span> <span class="o">=</span> <span class="s">&#39; </span><span class="si">%%</span><span class="s">-</span><span class="si">%d</span><span class="s">s : </span><span class="si">%%</span><span class="s">s</span><span class="se">\n</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">ml</span>
    <span class="n">s</span> <span class="o">=</span> <span class="s">&#39;&#39;</span>
    <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">n</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="p">:</span>
      <span class="k">if</span> <span class="n">key</span> <span class="o">==</span> <span class="s">&#39;X&#39;</span><span class="p">:</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">x</span><span class="p">())</span>
      <span class="k">elif</span> <span class="n">key</span> <span class="o">==</span> <span class="s">&#39;Y&#39;</span><span class="p">:</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">y</span><span class="p">())</span>
      <span class="k">elif</span> <span class="n">key</span> <span class="o">==</span> <span class="s">&#39;Z&#39;</span><span class="p">:</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">z</span><span class="p">())</span>
      <span class="k">elif</span> <span class="n">key</span> <span class="o">==</span> <span class="s">&#39;AByte&#39;</span><span class="p">:</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="s">&#39;Return Number&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">returnNumber</span><span class="p">())</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="s">&#39;Number Of Returns&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">numberOfReturns</span><span class="p">())</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="s">&#39;Scan Direction Flag&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">scanDirectionFlag</span><span class="p">())</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="s">&#39;Edge Of Flight Line&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">edgeOfFlightLine</span><span class="p">())</span>
      <span class="k">elif</span> <span class="n">key</span> <span class="o">==</span> <span class="s">&#39;2Bytes&#39;</span><span class="p">:</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="s">&#39;Return Number&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">returnNumber</span><span class="p">())</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="s">&#39;Number Of Returns&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">numberOfReturns</span><span class="p">())</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="s">&#39;Classification Flags&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">classificationFlags</span><span class="p">())</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="s">&#39;Scanner Channel&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">scannerChannel</span><span class="p">())</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="s">&#39;Scan Direction Flag&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">scanDirectionFlag</span><span class="p">())</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="s">&#39;Edge Of Flight Line&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">edgeOfFlightLine</span><span class="p">())</span>
      <span class="k">elif</span> <span class="n">key</span> <span class="o">==</span> <span class="s">&#39;Classification&#39;</span><span class="p">:</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">classification</span><span class="p">())</span>
      <span class="k">elif</span> <span class="n">key</span> <span class="o">==</span> <span class="s">&#39;ScanAngleRank&#39;</span><span class="p">:</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">scanAngleRank</span><span class="p">())</span>
      <span class="k">elif</span> <span class="n">key</span> <span class="o">==</span> <span class="s">&#39;UserData&#39;</span><span class="p">:</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">userData</span><span class="p">())</span>
      <span class="k">elif</span> <span class="n">key</span> <span class="o">==</span> <span class="s">&#39;GPSTime&#39;</span><span class="p">:</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">time</span><span class="p">())</span>
      <span class="k">else</span><span class="p">:</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="n">key</span><span class="p">,</span>
          <span class="n">string_clean</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__getattribute__</span><span class="p">(</span><span class="s">&#39;_</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">key</span><span class="p">)))</span>
    <span class="k">return</span> <span class="n">s</span>
</div>
  <span class="nd">@classmethod</span>
<div class="viewcode-block" id="PointDataRecord.getReturnNumber"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord.getReturnNumber">[docs]</a>  <span class="k">def</span> <span class="nf">getReturnNumber</span><span class="p">(</span><span class="n">cls</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return &#39;Return Number&#39; from `data` according to size in bytes</span>

<span class="sd">      :param data: one or two bytes to be interpreted</span>
<span class="sd">      :type  data: numpy array</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="n">data</span><span class="o">.</span><span class="n">itemsize</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
      <span class="k">return</span> <span class="p">(</span><span class="n">data</span> <span class="o">&amp;</span> <span class="mi">0</span><span class="n">b11100000</span><span class="p">)</span> <span class="o">&gt;&gt;</span> <span class="mi">5</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="k">return</span> <span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">&amp;</span> <span class="mi">0</span><span class="n">b11110000</span><span class="p">)</span> <span class="o">&gt;&gt;</span> <span class="mi">4</span>
</div>
<div class="viewcode-block" id="PointDataRecord.returnNumber"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord.returnNumber">[docs]</a>  <span class="k">def</span> <span class="nf">returnNumber</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return `Return Number` for this point:</span>

<span class="sd">        bits 0, 1, 2 (if Point format &lt; 6) or</span>
<span class="sd">        bits 0, 1, 2, 4</span>

<span class="sd">      :returns: &#39;Return Number&#39; for this point</span>
<span class="sd">      :rtype: int</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_format</span> <span class="o">&lt;</span> <span class="mi">6</span><span class="p">:</span>
      <span class="k">return</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_AByte</span> <span class="o">&amp;</span> <span class="mi">0</span><span class="n">b11100000</span><span class="p">)</span> <span class="o">&gt;&gt;</span> <span class="mi">5</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="k">return</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_2Bytes</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">&amp;</span> <span class="mi">0</span><span class="n">b11110000</span><span class="p">)</span> <span class="o">&gt;&gt;</span> <span class="mi">4</span>
</div>
<div class="viewcode-block" id="PointDataRecord.numberOfReturns"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord.numberOfReturns">[docs]</a>  <span class="k">def</span> <span class="nf">numberOfReturns</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return &#39;Number of Returns&#39; for this point:</span>

<span class="sd">        bits 3, 4, 5 (if Point format &lt; 6) or</span>
<span class="sd">        bits 4, 5, 6, 7</span>

<span class="sd">      :returns: &#39;Number of Returns&#39; for this point</span>
<span class="sd">      :rtype: int</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_format</span> <span class="o">&lt;</span> <span class="mi">6</span><span class="p">:</span>
      <span class="k">return</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_AByte</span> <span class="o">&amp;</span> <span class="mi">0</span><span class="n">b00011100</span><span class="p">)</span> <span class="o">&gt;&gt;</span> <span class="mi">2</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="k">return</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_2Bytes</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">&amp;</span> <span class="mi">0</span><span class="n">b00001111</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="PointDataRecord.classificationFlags"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord.classificationFlags">[docs]</a>  <span class="k">def</span> <span class="nf">classificationFlags</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return &#39;Classification Flags&#39; for this point:</span>

<span class="sd">        bits 0 - 3</span>

<span class="sd">      :returns: &#39;Classification Flags&#39; for this point</span>
<span class="sd">      :rtype: int</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_2Bytes</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">&amp;</span> <span class="mi">0</span><span class="n">b11110000</span><span class="p">)</span> <span class="o">&gt;&gt;</span> <span class="mi">4</span>
</div>
<div class="viewcode-block" id="PointDataRecord.scannerChannel"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord.scannerChannel">[docs]</a>  <span class="k">def</span> <span class="nf">scannerChannel</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return &#39;Scanner Channel&#39; for this point:</span>

<span class="sd">        bits 4, 5</span>

<span class="sd">      :returns: &#39;Scanner Channel&#39; for this point</span>
<span class="sd">      :rtype: int</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_2Bytes</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">&amp;</span> <span class="mi">0</span><span class="n">b00001100</span><span class="p">)</span> <span class="o">&gt;&gt;</span> <span class="mi">2</span>
</div>
<div class="viewcode-block" id="PointDataRecord.scanDirectionFlag"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord.scanDirectionFlag">[docs]</a>  <span class="k">def</span> <span class="nf">scanDirectionFlag</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return &#39;Scan Direction Flag&#39; for this point:</span>

<span class="sd">        bit 6</span>

<span class="sd">      :returns: &#39;Scan Direction Flag&#39; for this point</span>
<span class="sd">      :rtype: bool</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_format</span> <span class="o">&lt;</span> <span class="mi">6</span><span class="p">:</span>
      <span class="k">return</span> <span class="nb">bool</span><span class="p">((</span><span class="bp">self</span><span class="o">.</span><span class="n">_AByte</span> <span class="o">&amp;</span> <span class="mi">0</span><span class="n">b00000010</span><span class="p">)</span> <span class="o">&gt;&gt;</span> <span class="mi">1</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="k">return</span> <span class="nb">bool</span><span class="p">((</span><span class="bp">self</span><span class="o">.</span><span class="n">_2Bytes</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">&amp;</span> <span class="mi">0</span><span class="n">b00000010</span><span class="p">)</span> <span class="o">&gt;&gt;</span> <span class="mi">1</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="PointDataRecord.edgeOfFlightLine"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord.edgeOfFlightLine">[docs]</a>  <span class="k">def</span> <span class="nf">edgeOfFlightLine</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return &#39;Edge Of Flight Line&#39; for this point:</span>

<span class="sd">        bit 7</span>

<span class="sd">      :returns: &#39;Edge Of Flight Line&#39;</span>
<span class="sd">      :rtype: bool</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_format</span> <span class="o">&lt;</span> <span class="mi">6</span><span class="p">:</span>
      <span class="k">return</span> <span class="nb">bool</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_AByte</span> <span class="o">&amp;</span> <span class="mi">0</span><span class="n">b00000001</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="k">return</span> <span class="nb">bool</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_2Bytes</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">&amp;</span> <span class="mi">0</span><span class="n">b00000001</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="PointDataRecord.classification"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord.classification">[docs]</a>  <span class="k">def</span> <span class="nf">classification</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return classification integer value</span>

<span class="sd">      :returns: Classification integer value</span>
<span class="sd">      :rtype: int</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Classification</span> <span class="o">&amp;</span> <span class="mi">0</span><span class="n">b11111</span>
</div>
<div class="viewcode-block" id="PointDataRecord.userData"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord.userData">[docs]</a>  <span class="k">def</span> <span class="nf">userData</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return User Data integer value</span>

<span class="sd">      :returns: User Data integer value</span>
<span class="sd">      :rtype: int</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_UserData</span>
</div>
<div class="viewcode-block" id="PointDataRecord.scanAngleRank"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord.scanAngleRank">[docs]</a>  <span class="k">def</span> <span class="nf">scanAngleRank</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return Scan Angle Rank integer value</span>

<span class="sd">      :returns: Scan Angle Rank integer value</span>
<span class="sd">      :rtype: int</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ScanAngleRank</span>
</div>
<div class="viewcode-block" id="PointDataRecord.index"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord.index">[docs]</a>  <span class="k">def</span> <span class="nf">index</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return point index</span>

<span class="sd">      :returns: point index in LAS file</span>
<span class="sd">      :rtype: int</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_index</span>
</div>
<div class="viewcode-block" id="PointDataRecord.time"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord.time">[docs]</a>  <span class="k">def</span> <span class="nf">time</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return record time stamp (GPS Time)</span>

<span class="sd">      :returns: record time stamp</span>
<span class="sd">      :rtype: double</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">shift</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="o">.</span><span class="n">getVersionMinor</span><span class="p">()</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
      <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="o">.</span><span class="n">getGlobalEncoding</span><span class="p">()</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
        <span class="n">shift</span> <span class="o">=</span> <span class="mf">1e9</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_GPSTime</span> <span class="o">-</span> <span class="n">shift</span>
</div>
<div class="viewcode-block" id="PointDataRecord.x"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord.x">[docs]</a>  <span class="k">def</span> <span class="nf">x</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return x value</span>

<span class="sd">      :returns: x value</span>
<span class="sd">      :rtype: float</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_X</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="o">.</span><span class="n">getXscaleFactor</span><span class="p">()</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="o">.</span><span class="n">getXoffset</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="PointDataRecord.y"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord.y">[docs]</a>  <span class="k">def</span> <span class="nf">y</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return y value</span>

<span class="sd">      :returns: y value</span>
<span class="sd">      :rtype: float</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Y</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="o">.</span><span class="n">getYscaleFactor</span><span class="p">()</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="o">.</span><span class="n">getYoffset</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="PointDataRecord.z"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord.z">[docs]</a>  <span class="k">def</span> <span class="nf">z</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return z value</span>

<span class="sd">      :returns: z value</span>
<span class="sd">      :rtype: float</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Z</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="o">.</span><span class="n">getZscaleFactor</span><span class="p">()</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="o">.</span><span class="n">getZoffset</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="PointDataRecord.isReadMode"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.PointDataRecord.isReadMode">[docs]</a>  <span class="k">def</span> <span class="nf">isReadMode</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return True if Header is in &#39;read&#39; mode</span>

<span class="sd">      :returns: True if Header is in &#39;read&#39; mode</span>
<span class="sd">      :rtype: bool</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="o">.</span><span class="n">isReadMode</span><span class="p">()</span>

<span class="c">#===============================================================================</span></div></div>
<div class="viewcode-block" id="Header"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header">[docs]</a><span class="k">class</span> <span class="nc">Header</span><span class="p">(</span><span class="n">AbstractRecord</span><span class="p">):</span>
  <span class="sd">&quot;&quot;&quot; The LAS file header class</span>

<span class="sd">  .. note:: Formats from 1.0 to 1.4 are implemented.</span>
<span class="sd">  &quot;&quot;&quot;</span>
  <span class="n">GeneratingSoftware</span> <span class="o">=</span> <span class="s">&#39;ALASpy&#39;</span>
  <span class="c"># LAS 1.0</span>
  <span class="n">Las10</span> <span class="o">=</span> <span class="p">(</span>
    <span class="p">(</span><span class="s">&#39;FileSignature&#39;</span><span class="p">,</span>      <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span>   <span class="mi">4</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;Reserved&#39;</span>     <span class="p">,</span>      <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">ULONG</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;ProjectID_GUID1&#39;</span><span class="p">,</span>    <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">ULONG</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;ProjectID_GUID2&#39;</span><span class="p">,</span>    <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;ProjectID_GUID3&#39;</span><span class="p">,</span>    <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;ProjectID_GUID4&#39;</span><span class="p">,</span>    <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">UCHAR</span><span class="p">,</span>  <span class="mi">8</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;VersionMajor&#39;</span><span class="p">,</span>       <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">UCHAR</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;VersionMinor&#39;</span><span class="p">,</span>       <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">UCHAR</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;SystemIdentifier&#39;</span><span class="p">,</span>   <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span>  <span class="mi">32</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;GeneratingSoftware&#39;</span><span class="p">,</span> <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span>  <span class="mi">32</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;FileCreationDoY&#39;</span><span class="p">,</span>    <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;FileCreationYear&#39;</span><span class="p">,</span>   <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;HeaderSize&#39;</span><span class="p">,</span>         <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;OffsetToPointData&#39;</span><span class="p">,</span>  <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">ULONG</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;NumVarLenRecords&#39;</span><span class="p">,</span>   <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">ULONG</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;PointDataFormatID&#39;</span><span class="p">,</span>  <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">UCHAR</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;PointDataReclen&#39;</span><span class="p">,</span>    <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;NumPointRecords&#39;</span><span class="p">,</span>    <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">ULONG</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;NumPointsByReturn&#39;</span><span class="p">,</span>  <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">ULONG</span><span class="p">,</span>  <span class="mi">5</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;XscaleFactor&#39;</span><span class="p">,</span>       <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;YscaleFactor&#39;</span><span class="p">,</span>       <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;ZscaleFactor&#39;</span><span class="p">,</span>       <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;Xoffset&#39;</span><span class="p">,</span>            <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;Yoffset&#39;</span><span class="p">,</span>            <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;Zoffset&#39;</span><span class="p">,</span>            <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;Xmax&#39;</span><span class="p">,</span>               <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;Xmin&#39;</span><span class="p">,</span>               <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;Ymax&#39;</span><span class="p">,</span>               <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;Ymin&#39;</span><span class="p">,</span>               <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;Zmax&#39;</span><span class="p">,</span>               <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;Zmin&#39;</span><span class="p">,</span>               <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
  <span class="p">)</span>
  <span class="c"># LAS 1.1</span>
  <span class="n">Las11</span> <span class="o">=</span> <span class="p">(</span><span class="n">Las10</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="p">)</span> <span class="o">+</span> <span class="p">(</span>
    <span class="p">(</span><span class="s">&#39;FileSourceID&#39;</span><span class="p">,</span>       <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;Reserved&#39;</span><span class="p">,</span>           <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
  <span class="p">)</span> <span class="o">+</span> <span class="n">Las10</span><span class="p">[</span><span class="mi">2</span><span class="p">:]</span>
  <span class="c"># LAS 1.2</span>
  <span class="n">Las12</span> <span class="o">=</span> <span class="n">Las11</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">2</span><span class="p">]</span> <span class="o">+</span> <span class="p">(</span>
    <span class="p">(</span><span class="s">&#39;GlobalEncoding&#39;</span><span class="p">,</span>     <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
  <span class="p">)</span> <span class="o">+</span> <span class="n">Las11</span><span class="p">[</span><span class="mi">3</span><span class="p">:]</span>
  <span class="c"># LAS 1.3</span>
  <span class="n">Las13</span> <span class="o">=</span> <span class="n">Las12</span><span class="p">[:]</span> <span class="o">+</span> <span class="p">(</span>
    <span class="p">(</span><span class="s">&#39;StartOfWaveformDataPacketRec&#39;</span><span class="p">,</span>  <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">ULLONG</span><span class="p">,</span>   <span class="mi">1</span><span class="p">),</span>
  <span class="p">)</span>
  <span class="c"># LAS 1.4</span>
  <span class="n">Las14</span> <span class="o">=</span> <span class="n">Las13</span><span class="p">[:]</span> <span class="o">+</span> <span class="p">(</span>
    <span class="p">(</span><span class="s">&#39;StartOfFirstExtendedVLR&#39;</span><span class="p">,</span> <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">ULLONG</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;NumberOfExtendedVLR&#39;</span><span class="p">,</span>     <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">ULONG</span><span class="p">,</span>   <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;NumberOfPointRecords&#39;</span><span class="p">,</span>    <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">ULLONG</span><span class="p">,</span>  <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;NumberOfPointsByReturn&#39;</span><span class="p">,</span>  <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">ULLONG</span><span class="p">,</span> <span class="mi">15</span><span class="p">),</span>
  <span class="p">)</span>

  <span class="n">validPointDataFormats</span> <span class="o">=</span> <span class="p">{</span>
    <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">):</span> <span class="nb">range</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span>
    <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">):</span> <span class="nb">range</span><span class="p">(</span><span class="mi">2</span><span class="p">),</span>
    <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">):</span> <span class="nb">range</span><span class="p">(</span><span class="mi">4</span><span class="p">),</span>
    <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">):</span> <span class="nb">range</span><span class="p">(</span><span class="mi">6</span><span class="p">),</span>
    <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">):</span> <span class="nb">range</span><span class="p">(</span><span class="mi">10</span><span class="p">),</span>
  <span class="p">}</span>

<div class="viewcode-block" id="Header.__init__"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.__init__">[docs]</a>  <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">parent</span><span class="p">,</span> <span class="n">version</span><span class="o">=</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">),</span> <span class="n">pointDataFormatID</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Create a new :class:`Header` instance</span>

<span class="sd">      :param parent: LasObject or opened file</span>
<span class="sd">      :type  parent: :class:`LasObject` or opened file</span>
<span class="sd">      :param version: LAS file version</span>
<span class="sd">                      (ignored in read mode)</span>
<span class="sd">      :type  version: tuple</span>
<span class="sd">      :param pointDataFormatID: LAS point data format (ignored in read mode)</span>
<span class="sd">      :type pointDataFormatID: int</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_warnings</span> <span class="o">=</span> <span class="s">&quot;&quot;</span>

    <span class="c"># Las file object</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_parent</span> <span class="o">=</span> <span class="n">parent</span>
    <span class="c"># No geoinfo yet</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_wkt</span> <span class="o">=</span> <span class="bp">None</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_proj4</span> <span class="o">=</span> <span class="bp">None</span>

    <span class="c"># Read if in read mode or create appropriate header structure</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">isReadMode</span><span class="p">():</span>
      <span class="c"># Retrieve LAS file version</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">fid</span><span class="p">()</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="mi">24</span><span class="p">)</span>
      <span class="n">v</span> <span class="o">=</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">fid</span><span class="p">()</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="mi">1</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">fid</span><span class="p">()</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="mi">1</span><span class="p">))</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">fid</span><span class="p">()</span><span class="o">.</span><span class="n">seek</span><span class="p">(</span><span class="mi">0</span><span class="p">)</span>
      <span class="k">try</span><span class="p">:</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_version</span> <span class="o">=</span> <span class="p">(</span><span class="nb">ord</span><span class="p">(</span><span class="n">v</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> <span class="nb">ord</span><span class="p">(</span><span class="n">v</span><span class="p">[</span><span class="mi">1</span><span class="p">]))</span>
      <span class="k">except</span> <span class="ne">TypeError</span><span class="p">:</span>
        <span class="k">raise</span> <span class="n">InvalidLASFile</span><span class="p">(</span>
          <span class="s">&quot;LAS file &#39;</span><span class="si">%s</span><span class="s">&#39; is invalid: no version information.&quot;</span> <span class="o">%</span>
          <span class="bp">self</span><span class="o">.</span><span class="n">_parent</span><span class="o">.</span><span class="n">filename</span><span class="p">())</span>
      <span class="n">structure</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__getattribute__</span><span class="p">(</span><span class="s">&#39;Las</span><span class="si">%s%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_version</span><span class="p">)</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_createStructure</span><span class="p">(</span><span class="n">structure</span><span class="p">)</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_read</span><span class="p">()</span>

      <span class="c"># Create GUID from ProjectID_GUID fields</span>
      <span class="n">guid</span> <span class="o">=</span> <span class="p">(</span><span class="n">struct</span><span class="o">.</span><span class="n">pack</span><span class="p">(</span><span class="n">AbstractRecord</span><span class="o">.</span><span class="n">ULONG</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ProjectID_GUID1</span><span class="p">)</span> <span class="o">+</span>
        <span class="n">struct</span><span class="o">.</span><span class="n">pack</span><span class="p">(</span><span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ProjectID_GUID2</span><span class="p">)</span> <span class="o">+</span>
        <span class="n">struct</span><span class="o">.</span><span class="n">pack</span><span class="p">(</span><span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ProjectID_GUID3</span><span class="p">)</span> <span class="o">+</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_ProjectID_GUID4</span><span class="p">)</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_guid</span> <span class="o">=</span> <span class="n">uuid</span><span class="o">.</span><span class="n">UUID</span><span class="p">(</span><span class="n">bytes_le</span><span class="o">=</span><span class="n">guid</span><span class="p">)</span>
      <span class="c"># Read all records</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_varLenRecords</span> <span class="o">=</span> <span class="p">[]</span>
      <span class="k">for</span> <span class="n">dummy</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">getNumVarLenRecords</span><span class="p">()):</span>
        <span class="n">vlr</span> <span class="o">=</span> <span class="n">VLRecord</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
        <span class="c"># The key is (User_ID, Record_ID )</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_varLenRecords</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">vlr</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="c"># CREATION MODE</span>
      <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">version</span><span class="p">,</span> <span class="nb">tuple</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_version</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">version</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_warnings</span> <span class="o">+=</span> <span class="s">&quot;Version is NOT a tuple: set to </span><span class="si">%s</span><span class="s">.</span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_version</span>
      <span class="k">else</span><span class="p">:</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_version</span> <span class="o">=</span> <span class="n">version</span>
      <span class="n">structure</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__getattribute__</span><span class="p">(</span><span class="s">&#39;Las</span><span class="si">%s%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">_version</span><span class="p">)</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_createStructure</span><span class="p">(</span><span class="n">structure</span><span class="p">)</span>

      <span class="c"># Create a NEW GUID</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_guid</span> <span class="o">=</span> <span class="n">uuid</span><span class="o">.</span><span class="n">uuid4</span><span class="p">()</span>

      <span class="c"># Define default header structure and attributes</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_FileSignature</span>      <span class="o">=</span> <span class="s">&#39;LASF&#39;</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_Reserved</span>           <span class="o">=</span> <span class="mi">0</span>
      <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_version</span> <span class="o">&gt;=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_FileSourceID</span>     <span class="o">=</span> <span class="mi">0</span>
      <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_version</span> <span class="o">&gt;=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_GlobalEncoding</span>   <span class="o">=</span> <span class="mi">0</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_ProjectID_GUID1</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">unpack</span><span class="p">(</span>
        <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">ULONG</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_guid</span><span class="o">.</span><span class="n">bytes</span><span class="p">[:</span><span class="mi">4</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_ProjectID_GUID2</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">unpack</span><span class="p">(</span>
        <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_guid</span><span class="o">.</span><span class="n">bytes</span><span class="p">[</span><span class="mi">4</span><span class="p">:</span><span class="mi">6</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_ProjectID_GUID3</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">unpack</span><span class="p">(</span>
        <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_guid</span><span class="o">.</span><span class="n">bytes</span><span class="p">[</span><span class="mi">6</span><span class="p">:</span><span class="mi">8</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_ProjectID_GUID4</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_guid</span><span class="o">.</span><span class="n">bytes</span><span class="p">[</span><span class="mi">8</span><span class="p">:]</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_VersionMajor</span>       <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_version</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_VersionMinor</span>       <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_version</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_SystemIdentifier</span>   <span class="o">=</span> <span class="s">&#39;None&#39;</span><span class="o">.</span><span class="n">ljust</span><span class="p">(</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_getN4Key</span><span class="p">(</span><span class="s">&#39;SystemIdentifier&#39;</span><span class="p">))</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_GeneratingSoftware</span> <span class="o">=</span> <span class="n">pad_with_nulls</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">GeneratingSoftware</span><span class="p">,</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_getN4Key</span><span class="p">(</span><span class="s">&#39;GeneratingSoftware&#39;</span><span class="p">))</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_FileCreationDoY</span>    <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">time</span><span class="o">.</span><span class="n">gmtime</span><span class="p">()</span><span class="o">.</span><span class="n">tm_yday</span><span class="p">)</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_FileCreationYear</span>   <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">time</span><span class="o">.</span><span class="n">asctime</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_HeaderSize</span>         <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">sizeBytes</span><span class="p">()</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_OffsetToPointData</span>   <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_HeaderSize</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_NumVarLenRecords</span>   <span class="o">=</span> <span class="mi">0</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_setPDFID</span><span class="p">(</span><span class="n">pointDataFormatID</span><span class="p">)</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_NumPointRecords</span>     <span class="o">=</span> <span class="mi">0</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_NumPointsByReturn</span>  <span class="o">=</span> <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">)</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_XscaleFactor</span>       <span class="o">=</span> <span class="mf">0.01</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_YscaleFactor</span>       <span class="o">=</span> <span class="mf">0.01</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_ZscaleFactor</span>       <span class="o">=</span> <span class="mf">0.01</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_Xoffset</span>            <span class="o">=</span> <span class="mi">0</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_Yoffset</span>            <span class="o">=</span> <span class="mi">0</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_Zoffset</span>            <span class="o">=</span> <span class="mi">0</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_Xmax</span>               <span class="o">=</span> <span class="mi">0</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_Xmin</span>               <span class="o">=</span> <span class="mi">0</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_Ymax</span>               <span class="o">=</span> <span class="mi">0</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_Ymin</span>               <span class="o">=</span> <span class="mi">0</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_Zmax</span>               <span class="o">=</span> <span class="mi">0</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_Zmin</span>               <span class="o">=</span> <span class="mi">0</span>
      <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_version</span> <span class="o">&gt;=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">3</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_StartOfWaveformDataPacketRec</span> <span class="o">=</span> <span class="mi">0</span>
      <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_version</span> <span class="o">&gt;=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">):</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_StartOfFirstExtendedVLR</span>     <span class="o">=</span> <span class="mi">0</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_NumberOfExtendedVLR</span>         <span class="o">=</span> <span class="mi">0</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_NumberOfPointRecords</span>        <span class="o">=</span> <span class="mi">0</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_NumberOfPointsByReturn</span>      <span class="o">=</span> <span class="p">(</span>
          <span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="p">)</span> <span class="o">*</span> <span class="bp">self</span><span class="o">.</span><span class="n">_getN4Key</span><span class="p">(</span><span class="s">&#39;NumberOfPointsByReturn&#39;</span><span class="p">))</span>

      <span class="c"># No Variable Length Records yet</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_varLenRecords</span> <span class="o">=</span> <span class="p">[]</span>

    <span class="c"># Create Point Data Record instance</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_PointDataRecord</span> <span class="o">=</span> <span class="n">PointDataRecord</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Header.__repr__"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.__repr__">[docs]</a>  <span class="k">def</span> <span class="nf">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return :class:`Header` string representation</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">s</span> <span class="o">=</span> <span class="s">&#39;</span><span class="si">%s</span><span class="s">: Ver. </span><span class="si">%d</span><span class="s">.</span><span class="si">%d</span><span class="s"> - </span><span class="si">%d</span><span class="s"> bytes</span><span class="se">\n</span><span class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span>
      <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__class__</span><span class="o">.</span><span class="n">__name__</span><span class="p">,</span> <span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">_version</span> <span class="o">+</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">sizeBytes</span><span class="p">(),))</span>
    <span class="n">ml</span> <span class="o">=</span> <span class="n">getLongest</span><span class="p">([</span><span class="n">item</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="p">])</span>
    <span class="n">ff</span> <span class="o">=</span> <span class="s">&quot; </span><span class="si">%%</span><span class="s">-</span><span class="si">%d</span><span class="s">s : </span><span class="si">%%</span><span class="s">s</span><span class="se">\n</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">ml</span>
    <span class="n">ffc</span> <span class="o">=</span> <span class="s">&quot; </span><span class="si">%%</span><span class="s">-</span><span class="si">%d</span><span class="s">s : &#39;</span><span class="si">%%</span><span class="s">s&#39;</span><span class="se">\n</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">ml</span>
    <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">n</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="p">:</span>
      <span class="k">if</span> <span class="s">&#39;GUID4&#39;</span> <span class="ow">in</span> <span class="n">key</span><span class="p">:</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="s">&#39;Project ID / GUID&#39;</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_guid</span><span class="p">)</span>
      <span class="k">if</span> <span class="s">&#39;_GUID&#39;</span> <span class="ow">in</span> <span class="n">key</span><span class="p">:</span>
        <span class="k">continue</span>
      <span class="k">if</span> <span class="n">dtype</span> <span class="ow">in</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">UCHAR</span><span class="p">):</span>
        <span class="k">if</span> <span class="n">n</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
          <span class="c"># Format is char but content is a NUMBER!</span>
          <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">__getattribute__</span><span class="p">(</span><span class="s">&#39;_</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">key</span><span class="p">))</span>
        <span class="k">else</span><span class="p">:</span>
          <span class="n">sclean</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">string_clean</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__getattribute__</span><span class="p">(</span><span class="s">&#39;_</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">key</span><span class="p">)))</span>
          <span class="n">s</span> <span class="o">+=</span> <span class="n">ffc</span> <span class="o">%</span> <span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">sclean</span><span class="o">.</span><span class="n">ljust</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_getN4Key</span><span class="p">(</span><span class="n">key</span><span class="p">)))</span>
      <span class="k">else</span><span class="p">:</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="n">string_clean</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__getattribute__</span><span class="p">(</span><span class="s">&#39;_</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">key</span><span class="p">)))</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_warnings</span><span class="p">:</span>
      <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot;WARNINGS.....</span><span class="se">\n</span><span class="s">&quot;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">_warnings</span>
    <span class="k">return</span> <span class="n">s</span>
</div>
  <span class="k">def</span> <span class="nf">_read</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Read LAS header from file</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">isReadMode</span><span class="p">():</span>
      <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%s</span><span class="s"> not opened for reading&quot;</span> <span class="o">%</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__class__</span><span class="o">.</span><span class="n">__name__</span><span class="p">)</span>

    <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">n</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="p">:</span>
      <span class="n">nbytes</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">calcsize</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span> <span class="o">*</span> <span class="n">n</span>
      <span class="k">if</span> <span class="n">dtype</span> <span class="ow">in</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">UCHAR</span><span class="p">):</span>
        <span class="c"># string</span>
        <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">fid</span><span class="p">()</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="n">n</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">n</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
          <span class="c"># Format is char but content is a NUMBER!</span>
          <span class="n">value</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">unpack</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">value</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span>
      <span class="k">else</span><span class="p">:</span>
        <span class="k">if</span> <span class="n">n</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
          <span class="c"># tuple</span>
          <span class="n">value</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">unpack</span><span class="p">(</span><span class="n">dtype</span> <span class="o">*</span> <span class="n">n</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">fid</span><span class="p">()</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="n">nbytes</span><span class="p">))</span>
        <span class="k">else</span><span class="p">:</span>
          <span class="c"># single binary number</span>
          <span class="n">value</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">unpack</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">fid</span><span class="p">()</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="n">nbytes</span><span class="p">))[</span><span class="mi">0</span><span class="p">]</span>

          <span class="c"># Handle LAS 1.2 GlobalEncoding bit fields</span>
          <span class="k">if</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_version</span> <span class="o">&gt;=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">))</span> <span class="ow">and</span> <span class="p">(</span><span class="n">key</span> <span class="o">==</span> <span class="s">&#39;GlobalEncoding&#39;</span><span class="p">):</span>
            <span class="n">value</span> <span class="o">=</span> <span class="p">(</span><span class="mi">1</span> <span class="o">&lt;&lt;</span> <span class="mi">15</span><span class="p">)</span> <span class="o">&amp;</span> <span class="n">value</span>

      <span class="c"># Set attribute according to Header format</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__setattr__</span><span class="p">(</span><span class="s">&#39;_</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_PointDataFormatID</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">validPointDataFormats</span><span class="p">[</span><span class="bp">self</span><span class="o">.</span><span class="n">_version</span><span class="p">]:</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_warnings</span> <span class="o">+=</span> <span class="p">(</span>
        <span class="s">&quot;--&gt; PointDataFormatID </span><span class="si">%d</span><span class="s"> is invalid for version </span><span class="si">%s</span><span class="s">.</span><span class="si">%s</span><span class="se">\n</span><span class="s">&quot;</span> <span class="o">%</span>
        <span class="p">((</span><span class="bp">self</span><span class="o">.</span><span class="n">_PointDataFormatID</span><span class="p">,)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">_version</span><span class="p">))</span>

  <span class="k">def</span> <span class="nf">_setPDFID</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">pointDataFormatID</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Set Point Data Format ID</span>

<span class="sd">      :param pointDataFormatID: Point Data Format ID</span>
<span class="sd">      :type  pointDataFormatID: int</span>
<span class="sd">      :raises: :class:`~ALASpy.lasExceptions.InvalidPointDataFormatID`</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_PointDataFormatID</span>  <span class="o">=</span> <span class="n">pointDataFormatID</span>
    <span class="k">if</span> <span class="n">pointDataFormatID</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_PointDataReclen</span>  <span class="o">=</span> <span class="mi">20</span>
    <span class="k">elif</span> <span class="n">pointDataFormatID</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_PointDataReclen</span>  <span class="o">=</span> <span class="mi">28</span>
    <span class="k">elif</span> <span class="n">pointDataFormatID</span> <span class="ow">in</span> <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">)</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">_version</span> <span class="o">&gt;=</span> <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">):</span>
      <span class="k">if</span> <span class="n">pointDataFormatID</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_PointDataReclen</span>  <span class="o">=</span> <span class="mi">26</span>
      <span class="k">else</span><span class="p">:</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_PointDataReclen</span>  <span class="o">=</span> <span class="mi">34</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="k">raise</span> <span class="n">InvalidPointDataFormatID</span><span class="p">(</span>
        <span class="s">&quot;PointDataFormatID &#39;</span><span class="si">%d</span><span class="s">&#39; is invalid for version </span><span class="si">%d</span><span class="s">.</span><span class="si">%d</span><span class="s">&quot;</span> <span class="o">%</span>
        <span class="p">((</span><span class="n">pointDataFormatID</span><span class="p">,</span> <span class="p">)</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">_version</span><span class="p">))</span>

  <span class="k">def</span> <span class="nf">_getN4Key</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">key</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return number of elements for `key&#39; in header structure</span>

<span class="sd">      :returns: number of elements for `key&#39; in header structure or None</span>
<span class="sd">      :rtype: int</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">for</span> <span class="n">k</span><span class="p">,</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">n</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="p">:</span>
      <span class="k">if</span> <span class="n">key</span> <span class="o">==</span> <span class="n">k</span><span class="p">:</span>
        <span class="k">return</span> <span class="n">n</span>
    <span class="k">return</span> <span class="bp">None</span>

  <span class="k">def</span> <span class="nf">_setWkt</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Set WKT string to header</span>

<span class="sd">      :returns: False if self._wkt is False</span>
<span class="sd">      :rtype: bool</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_wkt</span><span class="p">:</span>
      <span class="n">geoKeys</span><span class="p">,</span> <span class="n">geoDoubleParams</span><span class="p">,</span> <span class="n">geoAsciiParams</span> <span class="o">=</span> <span class="n">geoKeysFromWkt</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_wkt</span><span class="p">)</span>

      <span class="c"># Create Mandatory Variable Length Records with Georeferencing Information</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_varLenRecords</span> <span class="o">=</span> <span class="p">[]</span>
      <span class="k">if</span> <span class="n">geoKeys</span><span class="p">:</span>
        <span class="n">vlr</span> <span class="o">=</span> <span class="n">VLRecord</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userID</span><span class="o">=</span><span class="n">VLRecord</span><span class="o">.</span><span class="n">LASProjection</span><span class="p">,</span>
          <span class="n">recordID</span><span class="o">=</span><span class="n">VLRecord</span><span class="o">.</span><span class="n">GeoKeyDirectoryKey</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">geoKeys</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">addVarLengthRecord</span><span class="p">(</span><span class="n">vlr</span><span class="p">)</span>
      <span class="k">if</span> <span class="n">geoDoubleParams</span><span class="p">:</span>
        <span class="n">vlr</span> <span class="o">=</span> <span class="n">VLRecord</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userID</span><span class="o">=</span><span class="n">VLRecord</span><span class="o">.</span><span class="n">LASProjection</span><span class="p">,</span>
          <span class="n">recordID</span><span class="o">=</span><span class="n">VLRecord</span><span class="o">.</span><span class="n">GeoDoubleParamsKey</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">geoDoubleParams</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">addVarLengthRecord</span><span class="p">(</span><span class="n">vlr</span><span class="p">)</span>
      <span class="k">if</span> <span class="n">geoAsciiParams</span><span class="p">:</span>
        <span class="n">vlr</span> <span class="o">=</span> <span class="n">VLRecord</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">userID</span><span class="o">=</span><span class="n">VLRecord</span><span class="o">.</span><span class="n">LASProjection</span><span class="p">,</span>
          <span class="n">recordID</span><span class="o">=</span><span class="n">VLRecord</span><span class="o">.</span><span class="n">GeoAsciiParamsKey</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="n">geoAsciiParams</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">addVarLengthRecord</span><span class="p">(</span><span class="n">vlr</span><span class="p">)</span>
      <span class="k">return</span> <span class="bp">True</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="k">return</span> <span class="bp">False</span>

<span class="c">#-------------------------------------------------------------------------------</span>
<span class="c"># Public methods</span>
<span class="c">#-------------------------------------------------------------------------------</span>
<div class="viewcode-block" id="Header.parent"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.parent">[docs]</a>  <span class="k">def</span> <span class="nf">parent</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return parent i.e. :class:`~ALASpy.las.LasObject` instance</span>

<span class="sd">      :returns: parent object</span>
<span class="sd">      :rtype: :class:`~ALASpy.las.LasObject`</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parent</span>
</div>
<div class="viewcode-block" id="Header.isReadMode"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.isReadMode">[docs]</a>  <span class="k">def</span> <span class="nf">isReadMode</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return True if Header is in &#39;read&#39; mode</span>

<span class="sd">      :returns: True if Header is in &#39;read&#39; mode</span>
<span class="sd">      :rtype: bool</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">fid</span><span class="p">()</span><span class="o">.</span><span class="n">mode</span><span class="o">.</span><span class="n">startswith</span><span class="p">(</span><span class="s">&#39;r&#39;</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Header.write"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.write">[docs]</a>  <span class="k">def</span> <span class="nf">write</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Write LAS Header AND Variable Length Records (if any) to file</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">isReadMode</span><span class="p">():</span>
      <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span><span class="s">&quot;</span><span class="si">%s</span><span class="s"> not opened for writing&quot;</span> <span class="o">%</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">__class__</span><span class="o">.</span><span class="n">__name__</span><span class="p">)</span>

    <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">size</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="p">:</span>
      <span class="n">nbytes</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">calcsize</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span> <span class="o">*</span> <span class="n">size</span>
      <span class="k">try</span><span class="p">:</span>
        <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__getattribute__</span><span class="p">(</span><span class="s">&#39;_</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">key</span><span class="p">)</span>
        <span class="k">if</span> <span class="n">dtype</span> <span class="ow">in</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">UCHAR</span><span class="p">):</span>
          <span class="k">if</span> <span class="n">size</span> <span class="o">==</span> <span class="mi">1</span><span class="p">:</span>
            <span class="c"># Format is char but content is a NUMBER!</span>
            <span class="n">s</span> <span class="o">=</span> <span class="nb">chr</span><span class="p">(</span><span class="n">value</span><span class="p">)</span>
          <span class="k">else</span><span class="p">:</span>
            <span class="c"># string, keep it</span>
            <span class="n">s</span> <span class="o">=</span> <span class="n">value</span>
        <span class="k">else</span><span class="p">:</span>
          <span class="k">if</span> <span class="n">size</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
            <span class="c"># tuple</span>
            <span class="n">s</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">pack</span><span class="p">(</span><span class="n">dtype</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">value</span><span class="p">),</span> <span class="o">*</span><span class="n">value</span><span class="p">)</span>
          <span class="k">else</span><span class="p">:</span>
            <span class="c"># single binary number</span>
            <span class="n">s</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">pack</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
      <span class="k">except</span><span class="p">:</span>
        <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s">&quot;Excepion on field &lt;</span><span class="si">%s</span><span class="s">&gt;&quot;</span> <span class="o">%</span> <span class="n">key</span><span class="p">)</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">fid</span><span class="p">()</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>

    <span class="c"># Write Variable Length Records (if any)</span>
    <span class="k">for</span> <span class="n">vlr</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_varLenRecords</span><span class="p">:</span>
      <span class="n">vlr</span><span class="o">.</span><span class="n">write</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="Header.close"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.close">[docs]</a>  <span class="k">def</span> <span class="nf">close</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Close LAS file object</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">fid</span><span class="p">():</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">fid</span><span class="p">()</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="Header.fid"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.fid">[docs]</a>  <span class="k">def</span> <span class="nf">fid</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return LAS file object</span>

<span class="sd">      :returns: LAS file object</span>
<span class="sd">      :rtype: :class:`file`</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="nb">hasattr</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_parent</span><span class="p">,</span> <span class="s">&#39;fid&#39;</span><span class="p">):</span>
      <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parent</span><span class="o">.</span><span class="n">fid</span><span class="p">()</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_parent</span>
</div>
<div class="viewcode-block" id="Header.offsets"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.offsets">[docs]</a>  <span class="k">def</span> <span class="nf">offsets</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return (x, y, z) offsets tuple</span>

<span class="sd">      :returns: (Xoffset, Yoffset, Zoffset)</span>
<span class="sd">      :rtype: tuple</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Xoffset</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Yoffset</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Zoffset</span>
</div>
<div class="viewcode-block" id="Header.setOffsets"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.setOffsets">[docs]</a>  <span class="k">def</span> <span class="nf">setOffsets</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ox</span><span class="p">,</span> <span class="n">oy</span><span class="p">,</span> <span class="n">oz</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Set coordinate offsets</span>

<span class="sd">      :param ox: x offset</span>
<span class="sd">      :type  ox: float</span>
<span class="sd">      :param oy: y offset</span>
<span class="sd">      :type  oy: float</span>
<span class="sd">      :param oz: z offset</span>
<span class="sd">      :type  oz: float</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_Xoffset</span> <span class="o">=</span> <span class="n">ox</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_Yoffset</span> <span class="o">=</span> <span class="n">oy</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_Zoffset</span> <span class="o">=</span> <span class="n">oz</span>
</div>
<div class="viewcode-block" id="Header.scaleFactors"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.scaleFactors">[docs]</a>  <span class="k">def</span> <span class="nf">scaleFactors</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return (x, y, z) scale factors tuple</span>

<span class="sd">      :returns: (XscaleFactor, YscaleFactor, ZscaleFactor)</span>
<span class="sd">      :rtype: tuple</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_XscaleFactor</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_YscaleFactor</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_ZscaleFactor</span>
</div>
<div class="viewcode-block" id="Header.version"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.version">[docs]</a>  <span class="k">def</span> <span class="nf">version</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return LAS File version tuple</span>

<span class="sd">      :returns: Las file version tuple</span>
<span class="sd">      :rtype: tuple</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_version</span>
</div>
<div class="viewcode-block" id="Header.xRange"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.xRange">[docs]</a>  <span class="k">def</span> <span class="nf">xRange</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return x coordinate range</span>

<span class="sd">      :returns: (Xmin, Xmax)</span>
<span class="sd">      :rtype: tuple</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Xmin</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Xmax</span>
</div>
<div class="viewcode-block" id="Header.yRange"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.yRange">[docs]</a>  <span class="k">def</span> <span class="nf">yRange</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return y coordinate range</span>

<span class="sd">      :returns: (Ymin, Ymax)</span>
<span class="sd">      :rtype: tuple</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Ymin</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Ymax</span>

</div>
<div class="viewcode-block" id="Header.zRange"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.zRange">[docs]</a>  <span class="k">def</span> <span class="nf">zRange</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return z coordinate range</span>

<span class="sd">      :returns: (Zmin, Zmax)</span>
<span class="sd">      :rtype: tuple</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Zmin</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Zmax</span>
</div>
<div class="viewcode-block" id="Header.setXRange"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.setXRange">[docs]</a>  <span class="k">def</span> <span class="nf">setXRange</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">xmin</span><span class="p">,</span> <span class="n">xmax</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Set x coordinate range</span>

<span class="sd">      :param xmin: x coordinate minimum value</span>
<span class="sd">      :type  xmin: float</span>
<span class="sd">      :param xmax: x coordinate maximum value</span>
<span class="sd">      :type  xmax: float</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_Xmin</span> <span class="o">=</span> <span class="n">xmin</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_Xmax</span> <span class="o">=</span> <span class="n">xmax</span>
</div>
<div class="viewcode-block" id="Header.setYRange"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.setYRange">[docs]</a>  <span class="k">def</span> <span class="nf">setYRange</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">ymin</span><span class="p">,</span> <span class="n">ymax</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Set y coordinate range</span>

<span class="sd">      :param ymin: y coordinate minimum value</span>
<span class="sd">      :type  ymin: float</span>
<span class="sd">      :param ymax: y coordinate maximum value</span>
<span class="sd">      :type  ymax: float</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_Ymin</span> <span class="o">=</span> <span class="n">ymin</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_Ymax</span> <span class="o">=</span> <span class="n">ymax</span>
</div>
<div class="viewcode-block" id="Header.setZRange"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.setZRange">[docs]</a>  <span class="k">def</span> <span class="nf">setZRange</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">zmin</span><span class="p">,</span> <span class="n">zmax</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Set z coordinate range</span>

<span class="sd">      :param zmin: z coordinate minimum value</span>
<span class="sd">      :type  zmin: float</span>
<span class="sd">      :param zmax: z coordinate maximum value</span>
<span class="sd">      :type  zmax: float</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_Zmin</span> <span class="o">=</span> <span class="n">zmin</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_Zmax</span> <span class="o">=</span> <span class="n">zmax</span>
</div>
<div class="viewcode-block" id="Header.setRanges"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.setRanges">[docs]</a>  <span class="k">def</span> <span class="nf">setRanges</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">minXYZ</span><span class="p">,</span> <span class="n">maxXYZ</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Set x, y, z coordinate ranges</span>

<span class="sd">      :param minXYZ: x, y, z coordinates minimum value</span>
<span class="sd">      :type  minXYZ: tuple</span>
<span class="sd">      :param maxXYZ: x, y, z coordinates maximum value</span>
<span class="sd">      :type  maxXYZ: tuple</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_Xmin</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Ymin</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Zmin</span> <span class="o">=</span> <span class="n">minXYZ</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_Xmax</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Ymax</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Zmax</span> <span class="o">=</span> <span class="n">maxXYZ</span>
</div>
<div class="viewcode-block" id="Header.setProjectGUID"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.setProjectGUID">[docs]</a>  <span class="k">def</span> <span class="nf">setProjectGUID</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">guid</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Set Project ID GUID fields</span>

<span class="sd">      :param guid: uuid</span>
<span class="sd">      :type  guid: :class:`uuid.UUID` version 4 instance</span>
<span class="sd">      :raises: :class:`IOError`, :class:`TypeError`</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">isReadMode</span><span class="p">():</span>
      <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span><span class="s">&quot;Cannot set Project ID GUID: file is opened for reading&quot;</span><span class="p">)</span>

    <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">guid</span><span class="p">,</span> <span class="n">uuid</span><span class="o">.</span><span class="n">UUID</span><span class="p">)</span> <span class="ow">and</span> <span class="n">guid</span><span class="o">.</span><span class="n">version</span> <span class="o">==</span> <span class="mi">4</span><span class="p">:</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_guid</span> <span class="o">=</span> <span class="n">guid</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_ProjectID_GUID1</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">unpack</span><span class="p">(</span>
        <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">ULONG</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_guid</span><span class="o">.</span><span class="n">bytes</span><span class="p">[:</span><span class="mi">4</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_ProjectID_GUID2</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">unpack</span><span class="p">(</span>
        <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_guid</span><span class="o">.</span><span class="n">bytes</span><span class="p">[</span><span class="mi">4</span><span class="p">:</span><span class="mi">6</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_ProjectID_GUID3</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">unpack</span><span class="p">(</span>
        <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_guid</span><span class="o">.</span><span class="n">bytes</span><span class="p">[</span><span class="mi">6</span><span class="p">:</span><span class="mi">8</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_ProjectID_GUID4</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_guid</span><span class="o">.</span><span class="n">bytes</span><span class="p">[</span><span class="mi">8</span><span class="p">:]</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="k">raise</span> <span class="ne">TypeError</span><span class="p">(</span><span class="s">&quot;Argument must be uuid.UUID version 4 instance&quot;</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Header.addVarLengthRecord"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.addVarLengthRecord">[docs]</a>  <span class="k">def</span> <span class="nf">addVarLengthRecord</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">vlr</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Add Varable Length Record</span>

<span class="sd">      :param vlr: Varable Length Record</span>
<span class="sd">      :type  vlr: :class:`VLRecord`</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_varLenRecords</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">vlr</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_NumVarLenRecords</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_varLenRecords</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_OffsetToPointData</span> <span class="o">+=</span> <span class="n">vlr</span><span class="o">.</span><span class="n">sizeBytes</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="Header.varLengthRecords"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.varLengthRecords">[docs]</a>  <span class="k">def</span> <span class="nf">varLengthRecords</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return Varable Length Record list</span>

<span class="sd">      :returns: Varable Length Record list</span>
<span class="sd">      :rtype: list</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_varLenRecords</span>
</div>
<div class="viewcode-block" id="Header.getVarLenRecord"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.getVarLenRecord">[docs]</a>  <span class="k">def</span> <span class="nf">getVarLenRecord</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">user_id</span><span class="p">,</span> <span class="n">record_id</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return Varable Length Record with with User_ID `user_id`</span>
<span class="sd">        and Record_ID `record_id`</span>

<span class="sd">      :param user_id: User_ID</span>
<span class="sd">      :type  user_id: string</span>
<span class="sd">      :param record_id: Record_ID</span>
<span class="sd">      :type  record_id: int</span>
<span class="sd">      :returns: Varable Length Record</span>
<span class="sd">      :rtype: :class:`VLRecord`</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">for</span> <span class="n">r</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_varLenRecords</span><span class="p">:</span>
      <span class="k">if</span> <span class="n">r</span><span class="o">.</span><span class="n">getID</span><span class="p">()</span> <span class="o">==</span> <span class="p">(</span><span class="n">user_id</span><span class="p">,</span> <span class="n">record_id</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">r</span>
</div>
<div class="viewcode-block" id="Header.wkt"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.wkt">[docs]</a>  <span class="k">def</span> <span class="nf">wkt</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return Well Known Text string or None</span>

<span class="sd">      :returns: WKT</span>
<span class="sd">      :rtype: string</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="n">osr</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
      <span class="k">return</span> <span class="bp">None</span>

    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_wkt</span><span class="p">:</span>
      <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_wkt</span>

    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_varLenRecords</span><span class="p">:</span>
      <span class="n">geoKeyDirectory</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">getVarLenRecord</span><span class="p">(</span>
        <span class="n">VLRecord</span><span class="o">.</span><span class="n">LASProjection</span><span class="p">,</span> <span class="n">VLRecord</span><span class="o">.</span><span class="n">GeoKeyDirectoryKey</span><span class="p">)</span>
      <span class="n">geoDoubleParams</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">getVarLenRecord</span><span class="p">(</span>
        <span class="n">VLRecord</span><span class="o">.</span><span class="n">LASProjection</span><span class="p">,</span> <span class="n">VLRecord</span><span class="o">.</span><span class="n">GeoDoubleParamsKey</span><span class="p">)</span>
      <span class="n">geoAsciiParams</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">getVarLenRecord</span><span class="p">(</span>
        <span class="n">VLRecord</span><span class="o">.</span><span class="n">LASProjection</span><span class="p">,</span> <span class="n">VLRecord</span><span class="o">.</span><span class="n">GeoAsciiParamsKey</span><span class="p">)</span>
      <span class="k">if</span> <span class="n">geoKeyDirectory</span><span class="p">:</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_wkt</span> <span class="o">=</span> <span class="n">normalize</span><span class="p">(</span><span class="n">geoKeyDirectory</span><span class="p">,</span> <span class="n">geoDoubleParams</span><span class="p">,</span> <span class="n">geoAsciiParams</span><span class="p">)</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_wkt</span>
</div>
<div class="viewcode-block" id="Header.prettyWkt"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.prettyWkt">[docs]</a>  <span class="k">def</span> <span class="nf">prettyWkt</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return pretty WKT string or None</span>

<span class="sd">      :returns: WKT</span>
<span class="sd">      :rtype: string</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">wkt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wkt</span><span class="p">()</span>
    <span class="k">if</span> <span class="n">wkt</span><span class="p">:</span>
      <span class="n">srs</span> <span class="o">=</span> <span class="n">osr</span><span class="o">.</span><span class="n">SpatialReference</span><span class="p">()</span>
      <span class="n">srs</span><span class="o">.</span><span class="n">ImportFromWkt</span><span class="p">(</span><span class="n">wkt</span><span class="p">)</span>
      <span class="k">return</span> <span class="n">srs</span><span class="o">.</span><span class="n">ExportToPrettyWkt</span><span class="p">()</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="k">return</span> <span class="bp">None</span>
</div>
<div class="viewcode-block" id="Header.proj4"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.proj4">[docs]</a>  <span class="k">def</span> <span class="nf">proj4</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return Proj4 string or None</span>

<span class="sd">      :returns: Proj4</span>
<span class="sd">      :rtype: string</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_proj4</span><span class="p">:</span>
      <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_proj4</span>

    <span class="n">wkt</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">wkt</span><span class="p">()</span>
    <span class="k">if</span> <span class="n">wkt</span><span class="p">:</span>
      <span class="n">srs</span> <span class="o">=</span> <span class="n">osr</span><span class="o">.</span><span class="n">SpatialReference</span><span class="p">()</span>
      <span class="n">srs</span><span class="o">.</span><span class="n">ImportFromWkt</span><span class="p">(</span><span class="n">wkt</span><span class="p">)</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_proj4</span> <span class="o">=</span> <span class="n">srs</span><span class="o">.</span><span class="n">ExportToProj4</span><span class="p">()</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_proj4</span>
</div>
<div class="viewcode-block" id="Header.setProj4"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.setProj4">[docs]</a>  <span class="k">def</span> <span class="nf">setProj4</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">proj4</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Set Proj4 string to header</span>

<span class="sd">      :param proj4: Proj.4 string</span>
<span class="sd">      :type  proj4: string</span>
<span class="sd">      :returns: False if :class:`osr` module is not available</span>
<span class="sd">      :rtype: bool</span>

<span class="sd">      .. note:: uses osr.SpatialReference() validation: ImportFromProj4 and</span>
<span class="sd">         ExportToProj4</span>
<span class="sd">      ..</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="n">osr</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
      <span class="k">return</span> <span class="bp">False</span>

    <span class="n">srs</span> <span class="o">=</span> <span class="n">osr</span><span class="o">.</span><span class="n">SpatialReference</span><span class="p">()</span>
    <span class="n">srs</span><span class="o">.</span><span class="n">ImportFromProj4</span><span class="p">(</span><span class="n">proj4</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_wkt</span> <span class="o">=</span> <span class="n">srs</span><span class="o">.</span><span class="n">ExportToWkt</span><span class="p">()</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_setWkt</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="Header.setWkt"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.setWkt">[docs]</a>  <span class="k">def</span> <span class="nf">setWkt</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">wkt</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Set WKT string to header</span>

<span class="sd">      :param wkt: WKT</span>
<span class="sd">      :type  wkt: string</span>
<span class="sd">      :returns: False if :class:`osr` module is not available</span>
<span class="sd">      :rtype: bool</span>

<span class="sd">      .. note:: uses osr.SpatialReference() validation: ImportFromWkt and</span>
<span class="sd">         ExportToWkt</span>
<span class="sd">      ..</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="n">osr</span> <span class="ow">is</span> <span class="bp">None</span><span class="p">:</span>
      <span class="k">return</span> <span class="bp">False</span>

    <span class="n">srs</span> <span class="o">=</span> <span class="n">osr</span><span class="o">.</span><span class="n">SpatialReference</span><span class="p">()</span>
    <span class="n">srs</span><span class="o">.</span><span class="n">ImportFromWkt</span><span class="p">(</span><span class="n">wkt</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_wkt</span> <span class="o">=</span> <span class="n">srs</span><span class="o">.</span><span class="n">ExportToWkt</span><span class="p">()</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_setWkt</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="Header.pointDataRecordDtype"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.pointDataRecordDtype">[docs]</a>  <span class="k">def</span> <span class="nf">pointDataRecordDtype</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return Point Data Record Dtype</span>

<span class="sd">      :returns: Point Data Record Dtype</span>
<span class="sd">      :rtype: :class:`numpy.dtype`</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_PointDataRecord</span><span class="o">.</span><span class="n">makeDtype</span><span class="p">(</span><span class="o">*</span><span class="n">args</span><span class="p">,</span> <span class="o">**</span><span class="n">kargs</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="Header.pointDataRecordSize"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.Header.pointDataRecordSize">[docs]</a>  <span class="k">def</span> <span class="nf">pointDataRecordSize</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return Point Data Record size in bytes</span>

<span class="sd">      :returns: Point Data Record size in bytes</span>
<span class="sd">      :rtype: int</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_PointDataRecord</span><span class="o">.</span><span class="n">sizeBytes</span><span class="p">()</span>

<span class="c">#===============================================================================</span></div></div>
<div class="viewcode-block" id="VLRecord"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.VLRecord">[docs]</a><span class="k">class</span> <span class="nc">VLRecord</span><span class="p">(</span><span class="n">AbstractRecord</span><span class="p">):</span>
  <span class="sd">&quot;&quot;&quot; The Variable Length Record item</span>
<span class="sd">  &quot;&quot;&quot;</span>
  <span class="n">LASProjection</span> <span class="o">=</span> <span class="s">&#39;LASF_Projection&#39;</span>
  <span class="n">User_Defined</span>  <span class="o">=</span> <span class="mi">32767</span>
  <span class="c"># Key number 1286 registered by</span>
  <span class="c"># Roberto Vidmar rvidmar@inogs.it since 20121010 to:</span>
  <span class="c"># OGS (Istituto Nazionale di Oceanografia e di Geofisica Sperimentale)</span>
  <span class="n">OGS</span> <span class="o">=</span> <span class="s">&#39;OGS&#39;</span>

  <span class="c"># Mandatory GeoTff tags</span>
  <span class="n">GeoKeyDirectoryKey</span> <span class="o">=</span> <span class="mi">34735</span>
  <span class="n">GeoDoubleParamsKey</span> <span class="o">=</span> <span class="mi">34736</span>
  <span class="n">GeoAsciiParamsKey</span>  <span class="o">=</span> <span class="mi">34737</span>
  <span class="n">GeoKeyDirectoryTag</span> <span class="o">=</span> <span class="p">(</span><span class="n">LASProjection</span><span class="p">,</span> <span class="n">GeoKeyDirectoryKey</span><span class="p">)</span>
  <span class="n">GeoDoubleParamsTag</span> <span class="o">=</span> <span class="p">(</span><span class="n">LASProjection</span><span class="p">,</span> <span class="n">GeoDoubleParamsKey</span><span class="p">)</span>
  <span class="n">GeoAsciiParamsTag</span>  <span class="o">=</span> <span class="p">(</span><span class="n">LASProjection</span><span class="p">,</span> <span class="n">GeoAsciiParamsKey</span><span class="p">)</span>

  <span class="n">Structure</span> <span class="o">=</span> <span class="p">(</span>
    <span class="p">(</span><span class="s">&#39;Reserved&#39;</span><span class="p">,</span>           <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span>   <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;User_ID&#39;</span><span class="p">,</span>            <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span>    <span class="mi">16</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;Record_ID&#39;</span><span class="p">,</span>          <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span>   <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;RecLenAfterHeader&#39;</span><span class="p">,</span>  <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span>   <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;Description&#39;</span><span class="p">,</span>        <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span>    <span class="mi">32</span><span class="p">))</span>

  <span class="n">Descriptions</span> <span class="o">=</span> <span class="nb">dict</span><span class="p">((</span>
    <span class="p">(</span><span class="mi">1024</span><span class="p">,</span> <span class="nb">dict</span><span class="p">((</span>
      <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="s">&#39;ModelTypeProjected&#39;</span><span class="p">),</span>
      <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="s">&#39;ModelTypeGeographic&#39;</span><span class="p">),</span>
      <span class="p">(</span><span class="mi">3</span><span class="p">,</span> <span class="s">&#39;ModelTypeGeocentric&#39;</span><span class="p">),</span>
      <span class="p">))),</span>
    <span class="p">(</span><span class="mi">1025</span><span class="p">,</span> <span class="nb">dict</span><span class="p">((</span>
      <span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="s">&#39;RasterPixelIsArea&#39;</span><span class="p">),</span>
      <span class="p">(</span><span class="mi">2</span><span class="p">,</span> <span class="s">&#39;RasterPixelIsPoint&#39;</span><span class="p">),</span>
      <span class="p">))),</span>
    <span class="p">))</span>

  <span class="n">GeoKey</span> <span class="o">=</span> <span class="p">(</span>
    <span class="p">(</span><span class="s">&#39;wKeyDirectoryVersion&#39;</span><span class="p">,</span> <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;wKeyRevision&#39;</span><span class="p">,</span>         <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;wMinorRevision&#39;</span><span class="p">,</span>       <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;wNumberOfKeys&#39;</span><span class="p">,</span>        <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>

  <span class="n">KeyEntry</span> <span class="o">=</span> <span class="p">(</span>
    <span class="p">(</span><span class="s">&#39;wKeyID&#39;</span><span class="p">,</span>           <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;wTIFFTagLocation&#39;</span><span class="p">,</span> <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;wCount&#39;</span><span class="p">,</span>           <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span>
    <span class="p">(</span><span class="s">&#39;wValue_Offset&#39;</span><span class="p">,</span>    <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">USHORT</span><span class="p">,</span> <span class="mi">1</span><span class="p">))</span>

<div class="viewcode-block" id="VLRecord.__init__"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.VLRecord.__init__">[docs]</a>  <span class="k">def</span> <span class="nf">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">header</span><span class="p">,</span> <span class="n">userID</span><span class="o">=</span><span class="s">&#39;&#39;</span><span class="p">,</span> <span class="n">recordID</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">description</span><span class="o">=</span><span class="s">&#39;&#39;</span><span class="p">,</span> <span class="n">data</span><span class="o">=</span><span class="bp">None</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Create a Variable Length Record instance</span>

<span class="sd">      :param header: LAS Header</span>
<span class="sd">      :type  header: :class:`Header`</span>
<span class="sd">      :param userID: user ID</span>
<span class="sd">      :type  userID: string</span>
<span class="sd">      :param recordID: record ID</span>
<span class="sd">      :type  recordID: int</span>
<span class="sd">      :param description: record description</span>
<span class="sd">      :type  description: string</span>
<span class="sd">      :param data: payload of the record</span>
<span class="sd">      :type  data: tuple or string according to (userID, recordID)</span>

<span class="sd">      .. note:: `data` is used only if LAS file is opened for writing</span>

<span class="sd">      .. note:: if userID is :class:`VLRecord.OGS` `data` can be any Python</span>
<span class="sd">                object that can be serialized by `cPickle.dumps`</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_header</span> <span class="o">=</span> <span class="n">header</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_createStructure</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">Structure</span><span class="p">)</span>
    <span class="bp">self</span><span class="o">.</span><span class="n">_warnings</span> <span class="o">=</span> <span class="s">&#39;&#39;</span>
    <span class="k">if</span> <span class="n">header</span><span class="o">.</span><span class="n">isReadMode</span><span class="p">():</span>
      <span class="n">fid</span> <span class="o">=</span> <span class="n">header</span><span class="o">.</span><span class="n">fid</span><span class="p">()</span>
      <span class="nb">super</span><span class="p">(</span><span class="n">VLRecord</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">_read</span><span class="p">(</span><span class="n">fid</span><span class="p">)</span>
      <span class="c"># Now read payload data</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_Data</span> <span class="o">=</span> <span class="n">fid</span><span class="o">.</span><span class="n">read</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_RecLenAfterHeader</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_Reserved</span> <span class="o">=</span> <span class="mi">0</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_User_ID</span> <span class="o">=</span> <span class="n">userID</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_Record_ID</span> <span class="o">=</span> <span class="n">recordID</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_Description</span> <span class="o">=</span> <span class="n">description</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_RecLenAfterHeader</span> <span class="o">=</span> <span class="mi">0</span>
      <span class="n">recID</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">getID</span><span class="p">()</span>
      <span class="k">if</span> <span class="n">recID</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">GeoDoubleParamsTag</span><span class="p">:</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_Data</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">pack</span><span class="p">(</span><span class="n">AbstractRecord</span><span class="o">.</span><span class="n">DOUBLE</span> <span class="o">*</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">),</span> <span class="o">*</span><span class="n">data</span><span class="p">)</span>
      <span class="k">elif</span> <span class="n">recID</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">GeoKeyDirectoryTag</span><span class="p">:</span>
        <span class="c"># data is a tuple of geokeys tuples:</span>
        <span class="n">geoKeys</span> <span class="o">=</span> <span class="n">data</span>
        <span class="c"># Set payload</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_Data</span> <span class="o">=</span> <span class="s">&#39;&#39;</span>
        <span class="n">j</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">size</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">GeoKey</span><span class="p">:</span>
          <span class="bp">self</span><span class="o">.</span><span class="n">_Data</span> <span class="o">+=</span> <span class="n">struct</span><span class="o">.</span><span class="n">pack</span><span class="p">(</span><span class="n">dtype</span> <span class="o">*</span> <span class="n">size</span><span class="p">,</span> <span class="n">geoKeys</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="n">j</span><span class="p">])</span>
          <span class="n">j</span> <span class="o">+=</span> <span class="mi">1</span>
        <span class="c"># Convert key entries</span>
        <span class="k">for</span> <span class="n">gk</span> <span class="ow">in</span> <span class="n">geoKeys</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span>
          <span class="n">j</span> <span class="o">=</span> <span class="mi">0</span>
          <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">size</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">KeyEntry</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_Data</span> <span class="o">+=</span> <span class="n">struct</span><span class="o">.</span><span class="n">pack</span><span class="p">(</span><span class="n">dtype</span> <span class="o">*</span> <span class="n">size</span><span class="p">,</span> <span class="n">gk</span><span class="p">[</span><span class="n">j</span><span class="p">])</span>
            <span class="n">j</span> <span class="o">+=</span> <span class="mi">1</span>
      <span class="k">elif</span> <span class="n">recID</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">OGS</span><span class="p">:</span>
        <span class="c"># data is a Python Object</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_Data</span> <span class="o">=</span> <span class="n">cPickle</span><span class="o">.</span><span class="n">dumps</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
      <span class="k">else</span><span class="p">:</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_Data</span> <span class="o">=</span> <span class="n">data</span>

    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">getID</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="bp">self</span><span class="o">.</span><span class="n">OGS</span> <span class="ow">and</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">getID</span><span class="p">()</span> <span class="ow">in</span> <span class="p">(</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">GeoKeyDirectoryTag</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">GeoDoubleParamsTag</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">GeoAsciiParamsTag</span><span class="p">):</span>
      <span class="c"># All other vlr records</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_warnings</span> <span class="o">+=</span> <span class="p">(</span>
        <span class="s">&quot;  --&gt; Unknown Variable Length Record with &quot;</span>
        <span class="s">&quot;User ID &#39;</span><span class="si">%s</span><span class="s">&#39; and Record ID &#39;</span><span class="si">%s</span><span class="s">&#39;</span><span class="se">\n</span><span class="s">&quot;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">getID</span><span class="p">())</span>

    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_RecLenAfterHeader</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">_RecLenAfterHeader</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">tagSizeBytes</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="VLRecord.__repr__"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.VLRecord.__repr__">[docs]</a>  <span class="k">def</span> <span class="nf">__repr__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Unambiguous representation of a :class:`VLRecord`</span>

<span class="sd">      :raises: :class:`ValueError`</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">headerSize</span> <span class="o">=</span> <span class="nb">super</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__class__</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">sizeBytes</span><span class="p">()</span>
    <span class="n">s</span> <span class="o">=</span> <span class="s">&#39;</span><span class="si">%s</span><span class="s">: Record_ID </span><span class="si">%d</span><span class="s">: </span><span class="si">%d</span><span class="s"> bytes (Header </span><span class="si">%d</span><span class="s"> + Data </span><span class="si">%d</span><span class="s">)</span><span class="se">\n</span><span class="s">&#39;</span> <span class="o">%</span> <span class="p">(</span>
      <span class="bp">self</span><span class="o">.</span><span class="n">__class__</span><span class="o">.</span><span class="n">__name__</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Record_ID</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">sizeBytes</span><span class="p">(),</span>
      <span class="n">headerSize</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_RecLenAfterHeader</span><span class="p">)</span>
    <span class="n">ml</span> <span class="o">=</span> <span class="n">getLongest</span><span class="p">([</span><span class="n">item</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">Structure</span><span class="p">])</span>
    <span class="n">ff</span> <span class="o">=</span> <span class="s">&#39;  </span><span class="si">%%</span><span class="s">-</span><span class="si">%d</span><span class="s">s : </span><span class="si">%%</span><span class="s">s</span><span class="se">\n</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">ml</span>
    <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">n</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">Structure</span><span class="p">:</span>
      <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="s">&#39;</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">key</span><span class="p">,</span> <span class="n">string_clean</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__getattribute__</span><span class="p">(</span><span class="s">&#39;_</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">key</span><span class="p">)))</span>
    <span class="c"># Tag descripion and length</span>
    <span class="n">s</span> <span class="o">+=</span> <span class="n">ff</span> <span class="o">%</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">tagName</span><span class="p">(),</span> <span class="s">&quot;</span><span class="si">%d</span><span class="s"> bytes&quot;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">tagSizeBytes</span><span class="p">())</span>
    <span class="n">recID</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">getID</span><span class="p">()</span>
    <span class="k">if</span> <span class="n">recID</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">OGS</span><span class="p">:</span>
      <span class="c"># Special OGS VLRecord, payload is a Python object!</span>
      <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot;  </span><span class="si">%s</span><span class="se">\n</span><span class="s">&quot;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">getData</span><span class="p">()</span><span class="o">.</span><span class="n">__repr__</span><span class="p">()</span>
    <span class="k">if</span> <span class="n">recID</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">GeoDoubleParamsTag</span><span class="p">:</span>
      <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot;  (</span><span class="si">%s</span><span class="s">)</span><span class="se">\n</span><span class="s">&quot;</span> <span class="o">%</span> <span class="s">&quot;, &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">([</span><span class="s">&quot;</span><span class="si">%.4f</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">p</span> <span class="k">for</span> <span class="n">p</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">getData</span><span class="p">()])</span>
    <span class="k">elif</span> <span class="n">recID</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">GeoAsciiParamsTag</span><span class="p">:</span>
      <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot;  </span><span class="si">%s</span><span class="se">\n</span><span class="s">&quot;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">getData</span><span class="p">()</span>
    <span class="k">elif</span> <span class="n">recID</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">GeoKeyDirectoryTag</span><span class="p">:</span>
      <span class="n">geoKeys</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">getData</span><span class="p">()</span>
      <span class="n">s</span> <span class="o">+=</span> <span class="p">(</span><span class="s">&quot;  Version: </span><span class="si">%d</span><span class="se">\n</span><span class="s">  Key_Revision: </span><span class="si">%d</span><span class="s">.</span><span class="si">%d</span><span class="se">\n</span><span class="s">  Number of keys: </span><span class="si">%d</span><span class="se">\n</span><span class="s">&quot;</span>
        <span class="s">&quot;  Keyed information:</span><span class="se">\n</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">geoKeys</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
      <span class="n">i</span> <span class="o">=</span> <span class="mi">1</span>
      <span class="k">for</span> <span class="n">wKeyID</span><span class="p">,</span> <span class="n">wTIFFTagLocation</span><span class="p">,</span> <span class="n">wCount</span><span class="p">,</span> <span class="n">wValue_Offset</span> <span class="ow">in</span> <span class="n">geoKeys</span><span class="p">[</span><span class="mi">1</span><span class="p">:]:</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot;  </span><span class="si">%2d</span><span class="s">) </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">i</span><span class="p">,</span> <span class="n">GeotiffKeys</span><span class="p">[</span><span class="n">wKeyID</span><span class="p">])</span>
        <span class="n">i</span> <span class="o">+=</span> <span class="mi">1</span>
        <span class="k">if</span> <span class="n">wTIFFTagLocation</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
          <span class="c"># 0 means data in the wValue_Offset field is an unsigned short</span>
          <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot; (Short, </span><span class="si">%d</span><span class="s">):&quot;</span> <span class="o">%</span> <span class="n">wCount</span>
          <span class="k">if</span> <span class="n">wKeyID</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">Descriptions</span><span class="p">:</span>
            <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot; </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">Descriptions</span><span class="p">[</span><span class="n">wKeyID</span><span class="p">][</span><span class="n">wValue_Offset</span><span class="p">]</span>
          <span class="k">else</span><span class="p">:</span>
            <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot; </span><span class="si">%s</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">GeotiffKeys</span><span class="p">[</span><span class="n">wValue_Offset</span><span class="p">]</span>
        <span class="k">elif</span> <span class="n">wTIFFTagLocation</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">GeoDoubleParamsKey</span><span class="p">:</span>
          <span class="c"># Data is located at index wValue_Offset of the</span>
          <span class="c"># GeoDoubleParamsTag</span>
          <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot; (Double, </span><span class="si">%d</span><span class="s">):&quot;</span> <span class="o">%</span> <span class="n">wCount</span>
          <span class="n">vlr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">header</span><span class="p">()</span><span class="o">.</span><span class="n">getVarLenRecord</span><span class="p">(</span>
            <span class="n">VLRecord</span><span class="o">.</span><span class="n">LASProjection</span><span class="p">,</span> <span class="n">wTIFFTagLocation</span><span class="p">)</span>
          <span class="n">s</span> <span class="o">+=</span> <span class="s">&#39; </span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">vlr</span><span class="o">.</span><span class="n">getData</span><span class="p">()[</span><span class="n">wValue_Offset</span><span class="p">]</span>
        <span class="k">elif</span> <span class="n">wTIFFTagLocation</span> <span class="o">==</span> <span class="n">VLRecord</span><span class="o">.</span><span class="n">GeoAsciiParamsKey</span><span class="p">:</span>
          <span class="c"># Data is located at index wValue_Offset of the</span>
          <span class="c"># GeoAsciiParamsTag</span>
          <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot; (Ascii, </span><span class="si">%d</span><span class="s">):&quot;</span> <span class="o">%</span> <span class="n">wCount</span>
          <span class="n">vlr</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">header</span><span class="p">()</span><span class="o">.</span><span class="n">getVarLenRecord</span><span class="p">(</span>
            <span class="n">VLRecord</span><span class="o">.</span><span class="n">LASProjection</span><span class="p">,</span> <span class="n">wTIFFTagLocation</span><span class="p">)</span>
          <span class="c"># We take 1 character less because strings should be null terminated</span>
          <span class="n">s</span> <span class="o">+=</span> <span class="s">&#39; &quot;</span><span class="si">%s</span><span class="s">&quot;&#39;</span> <span class="o">%</span> <span class="n">vlr</span><span class="o">.</span><span class="n">getData</span><span class="p">()[</span>
            <span class="n">wValue_Offset</span><span class="p">:</span> <span class="n">wValue_Offset</span> <span class="o">+</span> <span class="n">wCount</span> <span class="o">-</span> <span class="mi">1</span><span class="p">]</span>
        <span class="k">else</span><span class="p">:</span>
          <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
            <span class="s">&quot;Invalid wTIFFTagLocation </span><span class="si">%d</span><span class="s">&quot;</span> <span class="o">%</span> <span class="n">wTIFFTagLocation</span><span class="p">)</span>
        <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot;</span><span class="se">\n</span><span class="s">&quot;</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="k">pass</span>
    <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">_warnings</span><span class="p">:</span>
      <span class="n">s</span> <span class="o">+=</span> <span class="s">&quot;  WARNINGS.....</span><span class="se">\n</span><span class="s">&quot;</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">_warnings</span>
    <span class="k">return</span> <span class="n">s</span>

<span class="c">#-------------------------------------------------------------------------------</span>
<span class="c"># Public methods</span>
<span class="c">#-------------------------------------------------------------------------------</span></div>
<div class="viewcode-block" id="VLRecord.getData"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.VLRecord.getData">[docs]</a>  <span class="k">def</span> <span class="nf">getData</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return payload data</span>

<span class="sd">    :returns: payload data</span>
<span class="sd">    :rtype: * string or</span>
<span class="sd">            * tuple</span>
<span class="sd">            * Python Object (if userID is :class:`VLRecord.OGS`)</span>

<span class="sd">            according to (userID, recordID)</span>

<span class="sd">    .. note:: If this record is a :class:`VLRecord.GeoKeyDirectoryTag`</span>
<span class="sd">        returns something like this::</span>

<span class="sd">          (</span>
<span class="sd">          # a Version 1 GeoTIFF GeoKey, Rev. 1.0, 7 Keys</span>
<span class="sd">          (1,        1,      0,     7),</span>
<span class="sd">          #1024 = GTModelTypeGeoKey, 0=short, count = 1 Projected = 1, Offset 1</span>
<span class="sd">          (1024,     0,      1,     1),</span>
<span class="sd">          #1025 = GTRasterTypeGeoKey, 0=short, count=1, Projected=1, Offset 1</span>
<span class="sd">          (1025,     0,      1,     1),</span>
<span class="sd">          #1026 = GTCitationGeoKey, recordId 34737, 33 Bytes, Offset 0</span>
<span class="sd">          (1026, 34737,     33,     0),</span>
<span class="sd">          #2049 = GeogCitationGeoKey, recordId 34737, 7 bytes, Offset 33</span>
<span class="sd">          (2049, 34737,      7,    33),</span>
<span class="sd">          #2054 = GeogAngularUnitsGeoKey, 0=short, count=1, Ofset 9102</span>
<span class="sd">          (2054,     0,      1,  9102),</span>
<span class="sd">          (3072,     0,      1, 32630),</span>
<span class="sd">          (3076,     0,      1,  9001),</span>
<span class="sd">          )</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">recID</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">getID</span><span class="p">()</span>
    <span class="k">if</span> <span class="n">recID</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">GeoDoubleParamsTag</span><span class="p">:</span>
      <span class="n">data</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">unpack</span><span class="p">(</span>
      <span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_Data</span><span class="p">)</span> <span class="o">/</span> <span class="n">struct</span><span class="o">.</span><span class="n">calcsize</span><span class="p">(</span><span class="n">AbstractRecord</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">))</span> <span class="o">*</span>
      <span class="n">AbstractRecord</span><span class="o">.</span><span class="n">DOUBLE</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Data</span><span class="p">)</span>
    <span class="k">elif</span> <span class="n">recID</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">GeoKeyDirectoryTag</span><span class="p">:</span>
      <span class="n">payload</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Data</span>
      <span class="n">gkKeys</span> <span class="o">=</span> <span class="nb">list</span><span class="p">()</span>
      <span class="n">i</span> <span class="o">=</span> <span class="mi">0</span>
      <span class="n">geoKey</span> <span class="o">=</span> <span class="p">()</span>
      <span class="c"># Read directory</span>
      <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">size</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">GeoKey</span><span class="p">:</span>
        <span class="n">nbytes</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">calcsize</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span> <span class="o">*</span> <span class="n">size</span>
        <span class="n">geoKey</span> <span class="o">+=</span> <span class="p">(</span><span class="n">struct</span><span class="o">.</span><span class="n">unpack</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">payload</span><span class="p">[</span><span class="n">i</span><span class="p">:</span> <span class="n">i</span> <span class="o">+</span> <span class="n">nbytes</span><span class="p">])[</span><span class="mi">0</span><span class="p">],</span> <span class="p">)</span>
        <span class="n">i</span> <span class="o">+=</span> <span class="n">nbytes</span>
      <span class="n">gkKeys</span> <span class="o">=</span> <span class="p">(</span><span class="n">geoKey</span><span class="p">,</span> <span class="p">)</span>
      <span class="c"># Read key entries</span>
      <span class="k">for</span> <span class="n">dummy</span> <span class="ow">in</span> <span class="nb">xrange</span><span class="p">(</span><span class="n">geoKey</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">]):</span>
        <span class="n">keyEntry</span> <span class="o">=</span> <span class="p">()</span>
        <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">size</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">KeyEntry</span><span class="p">:</span>
          <span class="n">nbytes</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">calcsize</span><span class="p">(</span><span class="n">dtype</span><span class="p">)</span> <span class="o">*</span> <span class="n">size</span>
          <span class="n">keyEntry</span> <span class="o">+=</span> <span class="p">(</span><span class="n">struct</span><span class="o">.</span><span class="n">unpack</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">payload</span><span class="p">[</span><span class="n">i</span><span class="p">:</span> <span class="n">i</span> <span class="o">+</span> <span class="n">nbytes</span><span class="p">])[</span><span class="mi">0</span><span class="p">],</span> <span class="p">)</span>
          <span class="n">i</span> <span class="o">+=</span> <span class="n">nbytes</span>
        <span class="n">gkKeys</span> <span class="o">+=</span> <span class="p">(</span><span class="n">keyEntry</span><span class="p">,</span> <span class="p">)</span>
      <span class="n">data</span> <span class="o">=</span> <span class="n">gkKeys</span>
    <span class="k">elif</span> <span class="n">recID</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">OGS</span><span class="p">:</span>
      <span class="n">data</span> <span class="o">=</span> <span class="n">cPickle</span><span class="o">.</span><span class="n">loads</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_Data</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="n">data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Data</span>

    <span class="k">return</span> <span class="n">data</span>
</div>
<div class="viewcode-block" id="VLRecord.header"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.VLRecord.header">[docs]</a>  <span class="k">def</span> <span class="nf">header</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return Header instance</span>

<span class="sd">      :returns: header</span>
<span class="sd">      :rtype: :class:`Header`</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_header</span>
</div>
<div class="viewcode-block" id="VLRecord.write"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.VLRecord.write">[docs]</a>  <span class="k">def</span> <span class="nf">write</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Write instance to file</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="c">#self._Description = &#39;GTag&#39;</span>
    <span class="n">fid</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="o">.</span><span class="n">fid</span><span class="p">()</span>

    <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">dtype</span><span class="p">,</span> <span class="n">n</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">Structure</span><span class="p">:</span>
      <span class="k">if</span> <span class="n">dtype</span> <span class="ow">in</span> <span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">CHAR</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">UCHAR</span><span class="p">)</span> <span class="ow">and</span> <span class="n">n</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
        <span class="n">value</span> <span class="o">=</span> <span class="n">pad_with_nulls</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">__getattribute__</span><span class="p">(</span><span class="s">&#39;_</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">key</span><span class="p">),</span> <span class="n">n</span><span class="p">)</span>
        <span class="n">s</span> <span class="o">=</span> <span class="s">&#39;&#39;</span>
        <span class="k">for</span> <span class="n">byte</span> <span class="ow">in</span> <span class="n">value</span><span class="p">:</span>
          <span class="n">s</span> <span class="o">+=</span> <span class="n">struct</span><span class="o">.</span><span class="n">pack</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">byte</span><span class="p">)</span>
      <span class="k">else</span><span class="p">:</span>
        <span class="n">value</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">__getattribute__</span><span class="p">(</span><span class="s">&#39;_</span><span class="si">%s</span><span class="s">&#39;</span> <span class="o">%</span> <span class="n">key</span><span class="p">)</span>
        <span class="n">s</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">pack</span><span class="p">(</span><span class="n">dtype</span><span class="p">,</span> <span class="n">value</span><span class="p">)</span>
      <span class="n">fid</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">s</span><span class="p">)</span>
    <span class="n">fid</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_Data</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="VLRecord.getID"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.VLRecord.getID">[docs]</a>  <span class="k">def</span> <span class="nf">getID</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return unique Record ID tuple</span>

<span class="sd">      :returns: User_ID, Record_ID</span>
<span class="sd">      :rtype: tuple</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="n">nonull</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_User_ID</span><span class="p">),</span> <span class="bp">self</span><span class="o">.</span><span class="n">_Record_ID</span>
</div>
<div class="viewcode-block" id="VLRecord.sizeBytes"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.VLRecord.sizeBytes">[docs]</a>  <span class="k">def</span> <span class="nf">sizeBytes</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return size in bytes of this VLR</span>

<span class="sd">      :returns: size in bytes of this VLR</span>
<span class="sd">      :rtype: int</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_RecLenAfterHeader</span> <span class="o">+</span> <span class="nb">super</span><span class="p">(</span><span class="n">VLRecord</span><span class="p">,</span> <span class="bp">self</span><span class="p">)</span><span class="o">.</span><span class="n">sizeBytes</span><span class="p">()</span>
</div>
<div class="viewcode-block" id="VLRecord.tagName"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.VLRecord.tagName">[docs]</a>  <span class="k">def</span> <span class="nf">tagName</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return Tag name of this VLR</span>

<span class="sd">      :returns: Tag name of this VLR</span>
<span class="sd">      :rtype: string</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">recID</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">getID</span><span class="p">()</span>
    <span class="k">if</span> <span class="n">recID</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">GeoKeyDirectoryTag</span><span class="p">:</span>
      <span class="n">name</span> <span class="o">=</span> <span class="s">&quot;GeoKeyDirectoryTag&quot;</span>
    <span class="k">elif</span> <span class="n">recID</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">GeoDoubleParamsTag</span><span class="p">:</span>
      <span class="n">name</span> <span class="o">=</span> <span class="s">&quot;GeoDoubleParamsTag&quot;</span>
    <span class="k">elif</span> <span class="n">recID</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">GeoAsciiParamsTag</span><span class="p">:</span>
      <span class="n">name</span> <span class="o">=</span> <span class="s">&quot;GeoAsciiParamsTag&quot;</span>
    <span class="k">else</span><span class="p">:</span>
      <span class="n">name</span> <span class="o">=</span> <span class="s">&quot;User Defined Tag&quot;</span>
    <span class="k">return</span> <span class="n">name</span>
</div>
<div class="viewcode-block" id="VLRecord.tagSizeBytes"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.VLRecord.tagSizeBytes">[docs]</a>  <span class="k">def</span> <span class="nf">tagSizeBytes</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return Tag size in bytes for this VLR</span>

<span class="sd">      :returns: size in bytes of payload data</span>
<span class="sd">      :rtype: int</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="nb">len</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_Data</span><span class="p">)</span>
</div>
<div class="viewcode-block" id="VLRecord.isReadMode"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.VLRecord.isReadMode">[docs]</a>  <span class="k">def</span> <span class="nf">isReadMode</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
    <span class="sd">&quot;&quot;&quot; Return True if Header is in &#39;read&#39; mode</span>

<span class="sd">      :returns: True if Header is in &#39;read&#39; mode</span>
<span class="sd">      :rtype: bool</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_header</span><span class="o">.</span><span class="n">isReadMode</span><span class="p">()</span>

<span class="c">#===============================================================================</span></div></div>
<div class="viewcode-block" id="main"><a class="viewcode-back" href="../../ALASpy.html#ALASpy.header.main">[docs]</a><span class="k">def</span> <span class="nf">main</span><span class="p">():</span>
  <span class="n">pn</span> <span class="o">=</span> <span class="s">&#39;nicola_esempio.las&#39;</span>
  <span class="n">pn</span> <span class="o">=</span> <span class="s">&#39;/d0/Downloads/libLAS-1.7.0/test/data/1.0_0.las&#39;</span>
  <span class="k">print</span> <span class="n">Header</span><span class="p">(</span><span class="nb">open</span><span class="p">(</span><span class="n">pn</span><span class="p">,</span> <span class="s">&#39;r&#39;</span><span class="p">))</span>
  <span class="n">newpn</span> <span class="o">=</span> <span class="s">&#39;lasheader.las&#39;</span>
  <span class="n">new</span> <span class="o">=</span> <span class="n">Header</span><span class="p">(</span><span class="nb">open</span><span class="p">(</span><span class="n">newpn</span><span class="p">,</span> <span class="s">&#39;w&#39;</span><span class="p">),</span> <span class="n">version</span><span class="o">=</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="mi">4</span><span class="p">))</span>
  <span class="k">print</span> <span class="s">&quot;THE NEW HEADER</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">new</span>
  <span class="n">new</span><span class="o">.</span><span class="n">write</span><span class="p">()</span>
  <span class="n">new</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
  <span class="n">new1</span> <span class="o">=</span> <span class="n">Header</span><span class="p">(</span><span class="nb">open</span><span class="p">(</span><span class="n">newpn</span><span class="p">,</span> <span class="s">&#39;r&#39;</span><span class="p">))</span>
  <span class="k">print</span> <span class="s">&quot;HOW THE NEW HEADER LOOKS</span><span class="se">\n</span><span class="s">&quot;</span><span class="p">,</span> <span class="n">new1</span>
  <span class="k">print</span> <span class="s">&quot;Done&quot;</span>

<span class="c">#===============================================================================</span></div>
<span class="k">if</span> <span class="n">__name__</span> <span class="o">==</span> <span class="s">&#39;__main__&#39;</span><span class="p">:</span>
  <span class="n">main</span><span class="p">()</span>
</pre></div>

          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <p class="logo"><a href="../../index.html">
              <img class="logo" src="../../_static/ogs.png" alt="Logo"/>
            </a></p>
<div id="searchbox" style="display: none">
  <h3>Quick search</h3>
    <form class="search" action="../../search.html" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    <p class="searchtip" style="font-size: 90%">
    Enter search terms or a module, class or function name.
    </p>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li><a href="../../index.html">ALASpy 0.1.1 documentation</a> &raquo;</li>
          <li><a href="../index.html" >Module code</a> &raquo;</li> 
      </ul>
    </div>
    <div class="footer">
        &copy; Copyright 2012, Roberto Vidmar, Nicola Creati.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3.
    </div>
  </body>
</html>